You are on page 1of 15

Which of the following feature of C++ is NOT supported by Java and is therefore implemented using interfaces Choice a Choice

b Choice c Choice d Nested Classes Inner Classes Polymorphism Multiple Inheritance

7]

What will be the output of the following code, if executed with command line arguments as follows java cmdline Java is wonderful class cmdline { public static void main(String args[]) { for(int i=1;i<args.length;i++) { System.out.print(args[i]); if(i!=args.length) System.out.print( ); } System.out.println(); } }
Choice a Choice b Choice c Choice d Java Java is is wonderful cmdline Java is wonderful

[9] What is the process of assigning a smaller type to a larger one with respect to type conversion Choice a Choice b Choice casting Promotion narrowing

c Choice d implicit

class check { public static void main(String args[]) { boolean b=true; if(b) System.out.println("False"); System.out.println("True"); return; } } Choice a Choice b Choice c Choice d True False False True Error

n=5; r=n%3; if (r == 0) System.out.println(zero); else if (r ==1) System.out.println(one); else if (r == 2) System.out.println(two); else System.out.println(three); Choice a Choice b Choice c Choice d zero one two three

n=5; r=n%3; if (r == 0) System.out.println(zero); else if (r ==1) System.out.println(one); else if (r == 2) System.out.println(two); else System.out.println(three);

Choice a Choice b Choice c Choice d

zero one two three

class ifif { public static void main(String args[]) { int x=3, y=1,z=5; if(x>y) { if (z<=y) { System.out.println(y is greater than z); } else { System.out.println(z is greater than y); } System.out.println(x is greater than y); } else { if(y>z) { System.out.println(y is greater than z); } } } } Choice a Choice b Choice c Choice d z is greater than y x is greater than y y is greater than z x is greater than y x is greater than y x is greater than z x is greater than y z is greater than y

class ifif { public static void main(String args[]) { int x=3, y=1,z=5; if(x>y) { if (z<=y) {

System.out.println(y is greater than z); } else { System.out.println(z is greater than y); } System.out.println(x is greater than y); } else { if(y>z) { System.out.println(y is greater than z); } } } } Choice a Choice b Choice c Choice d z is greater than y x is greater than y y is greater than z x is greater than y x is greater than y x is greater than z x is greater than y z is greater than y

[16]

Which of the following portion specified in the for loop is compulsary


Choice a Choice b Choice c Choice d initialization test condition increment All of the above

What will be the output of the following code segment int r=100; while(true) { if(r<10) break; r=r-10; } System.out.print(r is +r); Choice a r is 0

Choice b Choice c Choice d

r is 10 r is 100 r is -10

Which of the following is a legal definition of an abstract class Choice a class student { abstract void display(); } abstract student { abstract void display(); } abstract class student { abstract void display(); } class abstract student { abstract void display(); }

Choice b

Choice c

Choice d

[24]

In the Interface definition what is TRUE for method declaration


Choice a Choice b Choice c Choice d List of methods declaration is only done Method declaration as well as body Only one Method declaration can be done Only one Methods body is allowed

class sample { public static void main(String args[]) { try { int a=Integer.parseInt(args[0]); int b=Integer.parseInt(args[1]); int c = a + b; System.out.println("Sum is "+c); } catch(ArithmeticException ae) { System.out.println("Arithmetic Exception "+ae.getMessage()); } catch(NumberFormatException ne) { System.out.println("Number Format Exception "+ne.getMessage()); } catch(Exception e) { System.out.println("Exception "+e); } }

} Choice a Choice b Choice c Choice d ArithmeticException NumberFormatException Exception None of the above

[1] What are user define data types and behave like built-in types of a programming language. Choice a Choice b Choice c Choice d [2] In OOP, the concept of Polymorphism is Choice a Choice b Choice c Choice d Reusability Ability to take more than one form Sharing of data Hiding of data Objects Methods Templates Classes

[3] Java is Robust, What statement explain this feature Choice a Choice b Choice c Choice d Java programs can be easily moved from one computer system to another Java systems verify memory access and virus Java can be used to create applications on the networks It provides many safeguards to ensure reliable code

Java is Platform-independent, What statement explain this feature Choice a Java programs can be easily moved from one computer system to another Java systems verify memory access and virus Java can be used to create applications on the networks

Choice b

Choice c

Choice d

It provides many safeguards to ensure reliable code

What is the right method of specifying the main method in Java Choice a Choice b private main (String args[]) public static int main(String args[]) public static void main (String args[]) public void static main (String args[])

Choice c

Choice d

What should be the source filename of a Java file Choice a Choice b Any name name matching any class name present in source file name matching the first class name in the source file name of the class containing the main method a=b=c=0; a='a' 0=b; c=72.25

Choice c

Choice d

Which of the following is NOT a valid assignment statement Choice a Choice b Choice c Choice d We cannot cast datatype double to which of the following datatype Choice a Choice b Choice c Choice d If the variable i & j are of type int, What is the value of j if j=i/2 Choice a Choice b Choice c 0.5 0.2 0 Byte char float boolean

Choice d What will be the output of the following code segment class sample { public static void main(String args[]) { int i=3,j=5; if ((i<j) || (i==3)) System.out.print(Yes); System.out.print(No); } } Choice a Choice b Choice c Choice d Which of the following form of Inheritance has one super class and many subclasses. Choice a Choice b Choice c Choice d

Yes No YesNo No output

Single Inheritance Multilevel Inheritance Hierarchical Inheritance Multiple Inheritance

What is NOT TRUE about static variable Choice a There are created by giving keyword static. only one copy of static variable is created for all instances of class. It must be accessed using object of class These are referred to as class variables. Method name Return type, Parameter list and body of method Parameter list Body of the method

Choice b

Choice c

Choice d

In method declaration statements, which of the following is optional Choice a Choice b

Choice c Choice d

Which of the following step is invalid for creating a package Choice a Declare the package in beginning of the file Define the classes to be put in the package & declare it public Create the listing as java in the Subdirectory by package menu Execute this java file

Choice b

Choice c

Choice d

What classes does the Java system package java.awt contain Choice a Classes for primitive types,Strings,Math functions, Threads and Exceptions Classes such as Vectors, hash tables, random numbers, date etc Classes for Input/Output support Classes for implementing graphical user interface

Choice b Choice c Choice d

In Multithreaded programming, what is the constant numeric value used for setting highest priority for Threads Choice a Choice b Choice c Choice d In Java, when a run-time error occurs which of the following may happen Choice a Choice b Choice c Choice compiles successfully produces wrong output abnormal termination All of the above 1 5 4 10

d In Java, which Exception type is caused by an attempt to access a nonexistent file Choice a Choice b Choice c Choice d FileNotFoundException IOException InvalidFileException IOException

Which exception may be thrown if the given code is executed giving 2 integer runtime arguments class sample { public static void main(String args[]) { try { int a=Integer.parseInt(args[0]); int b=Integer.parseInt(args[1]); int c = a + b; System.out.println("Sum is "+c); } catch(ArithmeticException ae) { System.out.println("Arithmetic Exception "+ae.getMessage()); } catch(NumberFormatException ne) { System.out.println("Number Format Exception "+ne.getMessage()); } catch(Exception e) { System.out.println("Exception "+e); } } } Choice a Choice b Choice c Choice d ArithmeticException NumberFormatException Exception None of the above

[3] What are Byte code instructions Choice a Choice b Choice It is Java Source Code It is code created by Java Compiler from the Source code It is machine code

c Choice d

generated by interpreter It is executable code generated by the compiler

[5] Which of the following is a valid identifier name that can be given in Java Choice a Choice b Choice c Choice d DayNday 1_num #alpha a.b

[6] Which of the following is NOT one of the Iteration statements available in Java Choice a Choice b Choice c Choice d for if do while

[9] Which of the following are Integer types in Java Choice a Choice b Choice c Choice d Byte Long Short All of the options 1,2,3

[11] What is the value of expression a<b?a++;++b if the value of a is 1 &

b is 2 Choice a Choice b Choice c Choice d 1 2 3 None of these

[13] Which of the following is True with respect to branching statements if & switch Choice a Choice b Choice c Choice d every if statement can be written using switch every switch statement must have a default case every case must end with a break statement every case label follows with a(:) colon

[14] What will be the output of the following program code class max { public static void main(String args[]) { int max=10; max(max,10,20); System.out.print(max); } static void max(int max,int x1,int x2) { if(x1>x2) max=x1; else max=x2; } } Choice a Choice b Choice 10 20 30

c Choice d 0

[17] Identify line numbers where logical errors occur in the following code so that factorial of 5 is calculated. 1 class factorial 2{ 3 public static void main(String args[]) 4{ 5 int n=0,fact=0; 6 for(int n=0;n>=1;n--) 7 fact=fact*1; 8 System.out.println(Factorial of 5 is +fact); 9} 10 } Choice a Choice b Choice c Choice d lines 5,6 lines 6 lines 7 lines 5,6,7

[18] Methods that can never be altered in any way are called as Choice a Choice b Choice c Choice d static methods abstract methods Member methods Final methods

[19] What is TRUE about nested methods Choice a Choice b Choice c Choice d They can be called using object of the class They can be called by giving its name, by another method of the same class where created. They can be called by giving its name, by another method of any class. They can be called using classname followed by dot, then the methodname

[20] When a method with same return type and a method with same name and arguments is defined in Super class as well as subclass. If the method in the subclass is invoked instead of the super class method, what is this concept known as Choice a Choice b Choice c Choice d Inheritance Method Overriding Method Overloading Final Method

[22] The method copyInto(array) is a method used with Choice a Choice b Choice c Choice d Arrays Strings StringBuffers Vectors

[25] What classes does the Java system package java.awt contain Choice a Choice b Choice c Choice d Classes for primitive types,Strings,Math functions, Threads and Exceptions Classes such as Vectors, hash tables, random numbers, date etc Classes for Input/Output support Classes for implementing graphical user interface

[29] In, Java Exception handling code when does the finally block execute Choice a It executes when any of the catch does not execute

Choice b Choice c Choice d

It executes allways It executes if the last catch executes It executes if the first catch executes

You might also like