Which of the following feature of C++ is NOT supported by Java and is therefore implemented using interfaces
Choice a
Nested Classes
Choice b
Inner Classes
Choice c
Polymorphism
Choice d
Multiple Inheritance
7]
What will be the output of the following code, if executed with command line arguments as follows java cmdline Java is wonderfulclass 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
Java
Choice b
Java is
Choice c
is wonderful
Choice d
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
casting
Choice b
Promotion
Choice c
narrowing
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 True
Choice b False
Choice c False True
Choice d Error
n=5;r=n%3;if (r == 0)System.out.println(“zero”);elseif (r ==1) System.out.println(“one”);elseif (r == 2)System.out.println(“two”);else System.out.println(“three”);
Choice a zero
Choice b one
Choice c two
Choice d three
n=5;r=n%3;if (r == 0)System.out.println(“zero”);elseif (r ==1) System.out.println(“one”);elseif (r == 2)System.out.println(“two”);else
System.out.println(“three”);
Choice a zero
Choice b one
Choice c two
Choice d 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 z is greater than yx is greater than y
Choice b y is greater than zx is greater than y
Choice c x is greater than yx is greater than z
Choice d x is greater than yz 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 z is greater than yx is greater than y
Choice b y is greater than zx is greater than y
Choice c x is greater than yx is greater than z
Choice d x is greater than yz is greater than y
[16] Which of the following portion specified in the for loop is compulsary
Choice a
initialization
Choice b
test condition
Choice c
increment
Choice d
All of the above
What will be the output of the following code segmentint r=100;while(true){if(r<10)break;r=r-10;}System.out.print(“r is “+r);
Choice a r is 0
Choice b r is 10
Choice c r is 100
Choice d r is -10
Which of the following is a legal definition of an abstract class
Choice a class student {abstract void display();}
Choice b abstract student {abstract void display();}
Choice c abstract class student {abstract void display();}
Choice d class abstract student {abstract void display();}
[24] In the Interface definition what is TRUE for method declaration
Choice a
List of methods declaration is only done
Choice b
Method declaration as well as body
Choice c
Only one Method declaration can be done
Choice d
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 ArithmeticException
Choice b NumberFormatException
Choice c Exception
Choice d None of the above
[1] What are user define data types and behave like built-in types of a programming language.
Choice a Objects
Choice b Methods
Choice c Templates
Choice d Classes
[2] In OOP, the concept of Polymorphism is
Choice a Reusability
Choice b Ability to take more than one form
Choice c Sharing of data
Choice d Hiding of data
[3] Java is Robust, What statement explain this feature
Choice a
Java programs can be easily moved from one computer system to another
Choice b
Java systems verify memory access and virus
Choice c
Java can be used to create applications on the networks
Choice d
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
Choice b Java systems verify memory access and virus
Choice c Java can be used to create applications on the networks
Choice d It provides many safeguards to ensure reliable code
What is the right method of specifying the main method in Java
Choice a private main (String args[])
Choice b public static int main(String args[])
Choice c public static void main (String args[])
Choice d public void static main (String args[])
What should be the source filename of a Java file
Choice a Any name
Choice b name matching any class name present in source file
Choice c name matching the first class name in the source file
Choice d name of the class containing the main method
Which of the following is NOT a valid assignment statement
Choice a a=b=c=0;
Choice b a='a'
Choice c 0=b;
Choice d c=72.25
We cannot cast datatype double to which of the following datatype
Choice a Byte
Choice b char
Choice c float
Choice d boolean
If the variable i & j are of type int, What is the value of j if j=i/2
Choice a 0.5
Choice b 0.2
Choice c 0
Choice d 1
What will be the output of the following code segmentclass 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 Yes
Choice b No
Choice c YesNo
Choice d No output
Which of the following form of Inheritance has one super class and many subclasses.
Choice a Single Inheritance
Choice b Multilevel Inheritance
Choice c Hierarchical Inheritance
Choice d Multiple Inheritance
What is NOT TRUE about static variable
Choice a There are created by giving keyword static.
Choice b only one copy of static variable is created for all instances of class.
Choice c It must be accessed using object of class
Choice d These are referred to as class variables.
In method declaration statements, which of the following is optional
Choice a Method name
Choice b Return type, Parameter list and body of method
Choice c Parameter list
Choice d Body of the method
Which of the following step is invalid for creating a package
Choice a Declare the package in beginning of the file
Choice b Define the classes to be put in the package & declare it public
Choice c Create the listing as java in the Subdirectory by package menu
Choice d Execute this java file
What classes does the Java system package java.awt contain
Choice a
Classes for primitive types,Strings,Math functions, Threads and Exceptions
Choice b
Classes such as Vectors, hash tables, random numbers, date etc
Choice c
Classes for Input/Output support
Choice d
Classes for implementing graphical user interface
In Multithreaded programming, what is the constant numeric
value used for setting highest priority for Threads
Choice a
1
Choice b
5
Choice c
4
Choice d
10
In Java, when a run-time error occurs which of the following may happen
Choice a
compiles successfully
Choice b
produces wrong output
Choice c
abnormal termination
Choice d
All of the above
In Java, which Exception type is caused by an attempt to access a nonexistent file
Choice a
FileNotFoundException
Choice b
IOException
Choice c
InvalidFileException
Choice d
IOException
Which exception may be thrown if the given code is executed giving 2 integer runtime argumentsclass 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
ArithmeticException
Choice b
NumberFormatException
Choice c
Exception
Choice d
None of the above
[3] What are Byte code instructions
Choice a
It is Java Source Code
Choice b
It is code created by Java Compiler from the Source code
Choice c
It is machine code generated by interpreter
Choice d
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 DayNday
Choice b 1_num
Choice c #alpha
Choice d a.b
[6] Which of the following is NOT one of the Iteration statements available in Java
Choice a
for
Choice b
if
Choice c
do
Choice d
while
[9] Which of the following are Integer types in Java
Choice a
Byte
Choice b
Long
Choice c
Short
Choice d
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
1
Choice b
2
Choice c
3
Choice d
None of these
[13] Which of the following is True with respect to branching statements if & switch
Choice a
every if statement can be written using switch
Choice b
every switch statement must have a default case
Choice c
every case must end with a break statement
Choice d
every case label follows with a(:) colon
[14] What will be the output of the following program codeclass 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;elsemax=x2;}}
Choice a
10
Choice b
20
Choice c
30
Choice d
0
[17] Identify line numbers where logical errors occur in the following code so that factorial of 5 is calculated.1 class factorial2 {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
lines 5,6
Choice b
lines 6
Choice c
lines 7
Choice d
lines 5,6,7
[18] Methods that can never be altered in any way are called as
Choice a static methods
Choice b abstract methods
Choice c Member methods
Choice d Final methods
[19] What is TRUE about nested methods
Choice a
They can be called using object of the class
Choice b
They can be called by giving its name, by another method of the same class where created.
Choice c
They can be called by giving its name, by another method of any class.
Choice d
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
Inheritance
Choice b
Method Overriding
Choice c
Method Overloading
Choice d
Final Method
[22] The method copyInto(array) is a method used with
Choice a
Arrays
Choice b
Strings
Choice c
StringBuffers
Choice d
Vectors
[25] What classes does the Java system package java.awt contain
Choice a
Classes for primitive types,Strings,Math functions, Threads and Exceptions
Choice b
Classes such as Vectors, hash tables, random numbers, date etc
Choice c
Classes for Input/Output support
Choice d
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
It executes allways
Choice c
It executes if the last catch executes
Choice d
It executes if the first catch executes
Top Related