main exam 4

33
Question 1 of 61 Which of the following correctly declare a variable which can hold an array of 10 integers? Select 2 correct options a int[ ] iA b int[10] iA c int iA[ ] d Object[ ] iA e Object[10] iA Question 2 of 61 Consider the following class : class Test { public static void main(String[] args) { for (int i = 0; i < 10; i++) System.out.print(i + " "); //1 for (int i = 10; i > 0; i--) System.out.print(i + " "); //2 int i = 20; //3 System.out.print(i + " "); //4 } } Which of the following statements are true? Select 4 correct options a As such the class will compile and print 20 in the last. b It will not compile if line 3 is removed. c It will not compile if line 3 is removed and placed before line 1. d It will not compile if line 4 is removed and placed before line 3. e Only Option 2, 3, and 4 are correct.

Upload: api-3752405

Post on 10-Apr-2015

280 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Main Exam 4

Question 1 of 61

Which of the following correctly declare a variable which can hold an array of 10 integers?

Select 2 correct optionsa int[ ] iA  

b int[10] iA  

c int iA[ ]  

d Object[ ] iA  

e Object[10] iA

Question 2 of 61

Consider the following class :

class Test{ public static void main(String[] args) { for (int i = 0; i < 10; i++) System.out.print(i + " "); //1 for (int i = 10; i > 0; i--) System.out.print(i + " "); //2 int i = 20; //3 System.out.print(i + " "); //4 }}

Which of the following statements are true?

Select 4 correct optionsa As such the class will compile and print 20 in the last.  

b It will not compile if line 3 is removed.  

c It will not compile if line 3 is removed and placed before line 1.  

d It will not compile if line 4 is removed and placed before line 3.  

e Only Option 2, 3, and 4 are correct.

Question 3 of 61

What will be the result of attempting to compile and run the following code?  public class Nesting{ public static void main(String args[])

Page 2: Main Exam 4

{ B.C obj = new B( ).new C( ); }}class A{ char c; A(char c) { this.c = c; }}class B extends A{ char c = 'a'; B( ) { super('b'); } class C extends A { char c = 'c'; C( ) { super('d'); System.out.println(B.this.c); System.out.println(C.this.c); System.out.println(super.c); } }}

Select 1 correct option.a It will not compile.  

b It will give RuntimeError.  

c The program will compile without error, and print a, c and d in that order when run.

 

d The program will compile without error, and print a, b and d in that order when run.

 

e The program will compile without error, and print b, c and a in that order when run.

Question 4 of 61

Which of the following statements are true?

Select 1 correct option.a A synchronized method cannot call another synchronized method in its body.  

b Making a synchronized method recursive will cause a deadlock.  

c Only non-static member variables are accessible in a synchronized method.  

d A synchronized method cannot be executed simultaneously by more than one thread on the same object.

 

e A synchronized method cannot call a non-synchronized method in its body.

Page 3: Main Exam 4

Question 5 of 61

Consider the following class definition:

public class TestClass{ public static void main(){ new TestClass().sayHello(); } //1 public static void sayHello(){ System.out.println("Static Hello World"); } //2 public void sayHello() { System.out.println("Hello World "); } //3}

What will be the result of compiling and running the class?

Select 1 correct option.a It will print 'Hello World'.  

b It will print 'Static Hello World'.  

c Compilation error at line 2.  

d Compilation error at line 3.  

e Runtime Error.

Question 6 of 61

What will be the result of attempting to compile and run the following class?

public class IfTest{ public static void main(String args[]) { if (true) if (false) System .out.println("True False"); else System.out.println("True True"); }}

                              

Select 1 correct option.a The code will fail to compile because the syntax of the if statement is not

correct. 

b The code will fail to compile because the values in the condition bracket are invalid.

 

c The code will compile correctly and will not display anything.  

d The code will compile correctly and will display 'True True'.  

e The code will compile correctly but will display 'True False'

Page 4: Main Exam 4

Question 7 of 61

Consider the following code:

class Test{ public static void main(String[] args) { for (int i = 0; i < args.length; i++) System.out.print(i == 0 ? args[i] : " " + args[i]); }}

What will be the output when it is run by giving the following command: java Test good bye friend!

Select 1 correct option.a It will print 'good bye friend!'  

b It will print 'good good good'  

c It will print 'goodgoodgood'  

d It will print 'good bye'  

e None of the above.

Question 8 of 61

Which of the following are valid declarations? Assume that \u0062 is the unicode value of b.

Select 3 correct optionsa char b = '\u0062' ;  

b char \u0062 = 'b' ;  

c ch\u0061r b = 'b' ;  

d char lf = '\u000a' ;     //  \u000a represents a line feed.

Question 9 of 61

Which of the following implementations of a max() method will correctly return the largest value?

// (1) int max(int x, int y) { return( if(x > y){ x; } else{ y; } ); }// (2)

Page 5: Main Exam 4

int max(int x, int y) { return( if(x > y){ return x; } else{ return y; } ); }// (3) int max(int x, int y) { switch(x < y) { case true: return y; default : return x; }; }// (4)int max(int x, int y){ if (x > y) return x; return y;}

Select 1 correct option.a 1  

b 2  

c 3  

d 4  

e None of the above.

Question 10 of 61

Following is a supposedly robust method to parse an input for a float.... Which of the following statements about the above method are true?? public float parseFloat(String s){ float f = 0.0f; try { f = Float.valueOf(s).floatValue(); return f ; } catch(NumberFormatException nfe) { System.out.println("Invalid input " + s); f = Float.NaN ; return f;

Page 6: Main Exam 4

} finally { System.out.println("finally"); } return f ;}

Select 1 correct option.a If input: "0.1" then it will return 0.1 and print finally.  

b If input: "0x.1" then it will return Float.Nan and print Invalid Input 0x.1and finally.

 

c If input: "1" then it will return 1 and print finally.  

d If input: "0x1" then it will return 0.0 and print Invalid Input 0x1 and finally.  

e The code will not compile.

Question 11 of 61

What will be the output of the following program?

public class EqualTest{ public static void main(String args[]) { Integer i = new Integer(1) ; Long m = new Long(1); if( i.equals(m)) System.out.println("equal"); // 1 else System.out.println("not equal"); }}

Select 1 correct option.a It will print 'equal'.  

b It will print 'not equal'.  

c Compile time error at  //1  

d Runtime error at  //1  

e None of the above.

Question 12 of 61

Which of the following are correct ways to initialize the static variables MAX  and CLASS_GUID ?

class Widget{ static int MAX; //1 static final String CLASS_GUID; // 2 Widget()

Page 7: Main Exam 4

{ //3 } Widget(int k) { //4 }}

Select 2 correct optionsa Modify lines //1 and //2 as :    static int MAX = 111;    static final String

CLASS_GUID = "XYZ123"; 

b Add the following line just after //2 :   static {   MAX = 111;    CLASS_GUID = "XYZ123";    }

 

c Add the following line just before //1 :   {  MAX = 111;    CLASS_GUID = "XYZ123";    }

 

d Add the following line at //3 as well as //4 :  MAX = 111;    CLASS_GUID = "XYZ123";

 

e Only option 3 is valid.

Question 13 of 61

Given the following classes and declarations, which of these statements about //1 and //2 are true?  class A{ private int i = 10; public void f(){} public void g(){}}class B extends A{ public int i = 20; public void g(){}}public class C{ A a = new A();//1 A b = new B();//2}

Select 1 correct option.a System.out.println(b.i); will print 10.  

b The statement b.f( ); will give compile time error..  

c System.out.println(b.i); will print 20  

d All the above are correct.  

e None of the above statements are correct.

Page 8: Main Exam 4

Question 14 of 61

You want to invoke the overridden method from the overriding method named m(). Write the construct which will let you do so.

 

 

Question 15 of 61

Which of the following lines can be inserted at line 1 to make the program run?

//line 1public class TestClass{ public static void main(String[] args) { PrintWriter pw = new PrintWriter(System.out); OutputStreamWriter osw = new OutputStreamWriter( System.out); pw.print("hello"); }}

Select 1 correct option.a import java.lang.*;  

b import java.io.*;  

c import java.io.OutputStreamWriter;  

d include java.io.*;  

e include java.lang.System

Question 16 of 61

Given the following code, which statements can be placed at the indicated position without causing compile and run time errors?

public class Test{ int i1; static int i2; public void method1() { int i; // ... insert statements here }

Page 9: Main Exam 4

}          

Select 3 correct optionsa i = this.i1;  

b i = this.i2;  

c this = new Test( );  

d this.i = 4;  

e this.i1 = i2;

Question 17 of 61

After what line string "string 2" will be eligible for garbage collection?  public class TestClass{ public static void main(String args[]) { String s ; String s1 = new String("string 1"); String s2 = new String("string 2"); String s3 = new String("string 3"); s = s2; s2 = null; //(1) s = s1 + s2 +s3; //(2) s1 = null ; //(3) s = null; //(4) s2 = null; //(5) s3 = null; //(6) }}

Select 1 correct option.a After the line labeled (1)  

b After the line labeled (2)  

c After the line labeled (3)  

d After the line labeled (4)  

e After the line labeled (5)

Question 18 of 61

Which of these are not part of the StringBuffer class?

Select 1 correct option.a trim( )  

b ensureCapacity(int )  

c append(boolean )  

Page 10: Main Exam 4

d reverse( )  

e setLength(int)

Question 19 of 61

Which one of the following class definitions is/are a legal definition of a class that cannot be instantiated? class Automobile{ abstract void honk(); //(1)}abstract class Automobile{ void honk(); //(2)}abstract class Automobile{ void honk(){}; //(3)}abstract class Automobile{ abstract void honk(){} //(4)}abstract class Automobile{ abstract void honk(); //(5)}

Select 2 correct optionsa 1  

b 2  

c 3  

d 4  

e 5

Question 20 of 61

Given the following classes, what will be the output of compiling and running the class Truck?

class Automobile{ public void drive() { System.out.println("Automobile: drive"); }}public class Truck extends Automobile{

Page 11: Main Exam 4

public void drive() { System.out.println("Truck: drive"); } public static void main (String args [ ]) { Automobile a = new Automobile(); Truck t = new Truck(); a.drive(); //1 t.drive(); //2 a = t; //3 a.drive(); //4 }}

Select 1 correct option.a Compiler error at line 3.  

b Runtime error at line 3.  

c It will print: Automobile: drive, Truck: drive, Automobile: drive, in that order.  

d It will print: Automobile: drive, Truck: drive, Truck: drive, in that order.  

e It will print: Automobile: drive,  Automobile: drive, Automobile: drive, in that order.

Question 21 of 61

Which of the following statements will correctly create and initialize an array of Strings to non null elements?

Select 4 correct optionsa String[] sA = new String[1] { "aaa"};  

b String[] sA = new String[] { "aaa"};  

c String[] sA = new String[1] ; sA[0] =  "aaa";  

d String[] sA = {new String( "aaa")};  

e String[] sA = { "aaa"};

Question 22 of 61

Which two of the following statements are equivalent?

Select 2 correct optionsa 3*2^2  

b 3<2  

c 3<<2  

d 3<<<2  

e 3*4

Page 12: Main Exam 4

Question 23 of 61

Which of the following statements are true?

Select 1 correct option.a For any non-null reference o1, the expression (o1 instanceof o1) will always

yield true. 

b For any non-null reference o1, the expression (o1 instanceof Object) will always yield true.

 

c For any non-null reference o1, the expression (o1 instanceof o1) will always yield false.

 

d For any non-null reference o1, the expression (o1 instanceof Object) may yield false.

 

e None of the above.

Question 24 of 61

Which statements about >> and >>> operators are correct?

Select 2 correct optionsa For non-negative values of the left operand, the >> and >>> operators will have

the same effect. 

b The >> operator does not chnage the leftmost bit of the lefthand side operand.  

c The value returned by >>> will never be negative .  

d The result of (-1 >>> 1) is -1.  

e The result of (-1 >> 1) is 0.

Question 25 of 61

Consider the following method...

public void ifTest(boolean flag){ if (flag) //1 if (flag) //2 System .out.println("True False"); else // 3 System.out.println("True True"); else // 4 System.out.println("False False");}

Which of the following statements are correct ?

Select 3 correct options

Page 13: Main Exam 4

a If run with an argument of 'false', it will print 'False False'  

b If run with an argument of 'false', it will print 'True True'  

c If run with an argument of 'true', it will print 'True False'  

d It will never print 'True True'  

e It will not compile.

Question 26 of 61

What will be the result of attempting to compile and run the following program?

public class MyThread implements Runnable{ String msg = "default"; public MyThread(String s) { msg = s; } public void run( ) { System.out.println(msg); } public static void main(String args[]) { new Thread(new MyThread("String1")).run(); new Thread(new MyThread("String2")).run(); System.out.println("end"); }}

     

Select 1 correct option.a The program will compile and print only 'end'.  

b It will always print 'String1'  'String2' and 'end', in that order.  

c It will always print 'String1'   'String2' in random order followed by 'end'.  

d It will always print 'end' first.  

e No order is guaranteed.

Question 27 of 61

Which of the following interfaces can be used to store a collection of non-duplicate objects in an unordered fashion ?

Select 1 correct option.

Page 14: Main Exam 4

a List  

b Map  

c Set  

d SortedList  

e SortedSet

Question 28 of 61

Which integral types in Java have a range of 2^16 integers? OR Which integral types in Java can represent exactly 2^16 distinct integers?

Select 2 correct optionsa char  

b int  

c long  

d short

Question 29 of 61

Which of the following code fragments are valid method declarations?

Select 1 correct option.a void method1{  }  

b void method2( ) {  }  

c void method3(void){  }  

d method4{  }  

e method5(void){  }

Question 30 of 61

Which of the following methods are available in the java.lang.Math class?

Select 2 correct optionsa double atan(double)  

b double atan2(double)  

c double itan(double)  

d double tan(double)  

e double invtan(double)

Page 15: Main Exam 4

Question 31 of 61

Which of the following code fragments show syntactically correct usage of assertions?

a.)public void assertTest(Object obj){

assert obj != null : throw AssertionError();}

b.)public void assertTest(Object o1, Object o2){

assert o1, o2 != null;}

c.)public void assertTest(Vector v){

assert v.isEmpty();}

d.)public void assertTest(){

assert;}

e.)public void assertTest(){

assert null;}

Select 1 correct option.a a  

b b  

c c  

d d  

e e

Question 32 of 61

What will be the result of attempting to compile and run the following class?

public class NumberTest{ public static void main(String args[])

Page 16: Main Exam 4

{ System.out.println(0x10 + 10 + 010); }}

Select 1 correct option.a Compilation error because of the expression 0x10 + 10 + 010.  

b When run, the program will print "28 ".  

c When run, the program will print "30 ".  

d When run, the program will print "34 ".  

e When run, the program will print "36 ".

Question 33 of 61

Which of the following statements regarding inner classes are true ?

Select 3 correct optionsa A non static inner class may have static members.  

b Anonymous inner classes cannot have any 'extends' or 'implements' clause.  

c Anonymous inner classes can only be created for interfaces.  

d Anonymous inner classes can never have initialization parameters.  

e Anonymous inner classes cannot be static.

Question 34 of 61

Which of the following statements are true?

Select 3 correct optionsa Interface Runnable is just a tag interface and has no methods.  

b Interface Runnable has one method.  

c class Thread implements Runnable.  

d All objects castable to Thread are castable to Runnable.  

e All objects castable to Runnable are castable to Thread.

Question 35 of 61

What is the name of the method that threads can use to pause their execution until signalled by another thread to continue ? (Do not include a parameter list or brackets or semicolon.)

Page 17: Main Exam 4

 

 

Question 36 of 61

An overriding method must have a same parameter list and same return type as that of  the overridden method.

Select 1 correct option.a True  

b False

Question 37 of 61

The following code will print 'false'.

float f = 1.0F/3.0F; System.out.println( (f * 3.0F) == 1.0F );

Select 1 correct option.a True  

b False

Question 38 of 61

What command should be given to compile and run a java source file named TestClass.java (for standard JDK)?

Select 1 correct option.a javac TestClass and java TestClass.class  

b javac TestClass.java and java TestClass  

c java TestClass.java and java TestClass  

d javac TestClass.java  and javac TestClass  

e None of the above.

Question 39 of 61

How many objects are eligible for garbage collection when the control reaches line 4 if the method process() is called with the argument of 5?

Page 18: Main Exam 4

1. public void process(int count) {2. for ( int i = 1; i < count; i++ ) {3. Object temp = new Object(); }4. }

Select 1 correct option.a 4  

b 5  

c 0  

d 1  

e 3

Question 40 of 61

The following code snippet will print  'true'.

float f = Integer.MAX_VALUE;int i = (int) f;System.out.println( i == Integer.MAX_VALUE);

Select 1 correct option.a True  

b False

Question 41 of 61

Which statements regarding the following code are correct ?

 class Base{ // NullPointerException is a subclass of RunTimeException.

Page 19: Main Exam 4

// IOException is a not subclass of RunTimeException. void method1() throws java.io.IOException, NullPointerException { someMethod("arguments"); // some I/O operations } int someMethod(String str) { if(str == null) throw new NullPointerException(); else return str.length(); }}public class NewBase extends Base{ void method1() { someMethod("args"); }}

Select 2 correct optionsa method1 in class NewBase does not need to specify any exceptions.  

b The code will not compile as RuntimeExceptions cannot be given in throws clause.

 

c method1 in class NewBase must atleast give 'IOException' in it's throws clause.  

d method1 in class NewBase must atleast give 'NullpointerException' in it's throws clause.

 

e There is no problem wih the code.

Question 42 of 61

Which of these statements about interfaces are true?

Select 3 correct optionsa Interfaces are abstract by default.  

b An interface can have static methods.  

c All methods in an interface are abstract although you need not declare them to be so.

 

d Fields of an interface may be declared as transient or volatile but not synchronized.

 

e interfaces cannot be final.

Question 43 of 61

What is the result of executing the following code when the value of i is 5:

switch (i)

Page 20: Main Exam 4

{ default: case 1: System.out.println(1); case 0: System.out.println(0); case 2: System.out.println(2); break; case 3: System.out.println(3);}

Select 1 correct option.a It will print 1 0 2  

b It will print 1 0 2 3  

c It will print 1 0  

d It will print 1  

e Nothing will be printed.

Question 44 of 61

Which statements concerning conversion are true?

Select 4 correct optionsa Conversion from char to long does not need a cast.  

b Conversion from byte to short does not need a cast.  

c Conversion from short to char needs a cast.  

d Conversion from int to float need a cast.  

e Conversion from byte, char or short to int, long or float does not need a cast.

Question 45 of 61

Which of the following code fragments will successfully initialize a two-dimensional array of chars named cA with a size such that cA[2][3] refers to a valid element?

1. char[][] cA = { { 'a', 'b', 'c' }, { 'a', 'b', 'c' } };2. char cA[][] = new char[3][]; for (int i=0; i<cA.length; i++) cA[i] = new char[4];3. char cA[][] = { new char[ ]{ 'a', 'b', 'c' } , new char[ ]{ 'a', 'b', 'c' } };4

Page 21: Main Exam 4

char cA[3][2] = new char[][] { { 'a', 'b', 'c' }, { 'a', 'b', 'c' } };5. char[][] cA = { "1234", "1234", "1234" };

Select 1 correct option.a 1, 3  

b 4, 5  

c 2, 3  

d 1, 2, 3  

e 2

Question 46 of 61

Consider the following code that uses an assertion to ensure that the program is supplied with 2 arguments:

public class TestClass{

public static void main(String[] args){

assert args.length == 2 : "Must give two arguments";...

}}

Which of the given statements regarding the above code are correct?

Select 1 correct option.a This is an appropriate use of assertions.  

b The programmer should throw a RuntimeException instead of using an assertion in this case.

 

c The given code is syntactically incorrect.  

d Assertions cannot be used in a static method.

Question 47 of 61

Which is the first line that will cause compilation to fail in the following program?

// Filename: A.javaclass A{ public static void main(String args[]) { A a = new A(); B b = new B(); a = b; // 1

Page 22: Main Exam 4

b = a; // 2 a = (B) b; // 3 b = (B) a; // 4 }}class B extends A { }

    

Select 1 correct option.a At Line 1.  

b At Line 2.  

c At Line 3.  

d At Line 4.  

e None of the above.

Question 48 of 61

What classes/interfaces can be used to store key - value pairs?

Select 3 correct optionsa java.util.Hashtable  

b java.util.Set  

c java.util.SortedSet  

d java.util.Map  

e java.util.SortedMap

Question 49 of 61

Which of the following are wrapper classes for primitive types?

Select 1 correct option.a java.lang.String  

b java.lang.Void  

c java.lang.Null  

d java.lang.Object  

e None of the above

Question 50 of 61

Write the name of the interface that can be implemented by a class so that it can execute in a seperate thread?

Page 23: Main Exam 4

(Do not put spaces, brackets or any other special charaters)

 

 

Question 51 of 61

What should be inserted at //line 1 to make sure that it prints h.i = 20?  class Hello implements Runnable{ int i; public void run(){ try { Thread.sleep(3000); } catch (InterruptedException e){} i = 20; }}public class Test{ static public void main(String[] args) throws Exception{ Hello h = new Hello(); Thread t = new Thread(h); t.start(); //line 1 System.out.println("h.i = " + h.i); }}a. h.wait()b. t.wait()c. y.yield()d. t.join()e. h.notify()f. t.notify()g. t.interrupt()

Select 1 correct option.a any one of a, b, g  

b any one of c, e, f  

c any one of c, d, f  

d Only d  

e Only b

Question 52 of 61

Given the following pairs of method declarations, which of the statements are true?

1.

Page 24: Main Exam 4

void perform_work(int time){ }int perform_work(int time, int speed){ return time*speed ;}2.void perform_work(int time){ }int perform_work(int speed){return speed ;}3.void perform_work(int time){ }void Perform_work(int time){ }

Select 2 correct optionsa The first pair of methods will compile correctly and overload the

method  'perform_work'. 

b The second pair of methods will compile correctly and overload the method  'perform_work'.

 

c The third pair of methods will compile correctly and overload the method 'perform_work'.

 

d The second pair of methods will not compile correctly.  

e The third pair of methods will not compile correctly.

Question 53 of 61

Which of these parameter lists do not have a corresponding constructor in the String class?

Select 1 correct option.a ( )  

b (int capacity)  

c (char[ ] data)  

d (String str)  

e (StringBuffer sb)

Question 54 of 61

What will be the output when the following class is compiled and run?

class ScopeTest{ static int x = 5; public static void main(String[] args) { int x = ( x=3 ) * 4; // 1 System.out.println(x); }}

Page 25: Main Exam 4

Select 1 correct option.a It will not compile because line //1 cannot be parsed correctly.  

b It will not compile because x is used before initialization.  

c It will not compile because there is an ambigous reference to x.  

d It will print 12.  

e It will print 3 .

Question 55 of 61

Which expressions will evaluate to true if preceded by the following code?

String a = "java"; char[] b = { 'j', 'a', 'v', 'a' }; String c = new String(b); String d = a;

Select 3 correct optionsa (a == d)  

b (b == d)  

c (a == "java")  

d a.equals(c)

Question 56 of 61

Consider these two interfaces:

interface I1{ void m1() throws IOException;}interface I2{ void m1() throws SQLException;}

What methods have to be implemented by a class that says it implements I1 and I2 ?

Select 1 correct option.a Both, public void m1() throws SQLException; and public void m1() throws

IOException; 

b public void m1() throws Exception  

c The class cannot implement both the interfaces as they have conflicting methods.

 

d public void m1() throws SQLException, IOException;  

Page 26: Main Exam 4

e None of the above.

Question 57 of 61

Which interfaces does java.util.Hashtable implement?

Select 1 correct option.a java.util.SortedSet  

b java.util.Map  

c java.util.SortedMap  

d java.util.TreeMap  

e java.util.List

Question 58 of 61

Given the following class definition:

class A{ protected int i; A(int i) { this.i = i; }}

Which of the following would be a valid inner class for this class?

Select 2 correct optionsa class B {}  

b class B extends A {}  

c class B {     B()   {     System.out.println("i = " + i);  }         }  

d class B {    class A {}    }  

e class A {}

Question 59 of 61

Which of these statements are true?

Select 3 correct optionsa Non-static inner class cannot have static members.  

b Objects of top level nested classes can be created without creating instances of their Outer classes.

 

Page 27: Main Exam 4

c Member variables in any nested class cannot be declared final.  

d Anonymous classes cannot have constructors.  

e Anonymous classes cannot be static.

Question 60 of 61

What happens when a method calls wait() without ensuring that the current thread owns the monitor of the object?

Select 1 correct option.a The code will fail to compile.  

b If the thread does not have the monitor and if the monitor is free then no exception will be thrown.

 

c An IllegalMonitorStateException will be thrown whenever the method is called.  

d An IllegalMonitorStateException will be thrown if current thread does not have the monitor of the object .

 

e The thread will be blocked until it gains the monitor of the object.

Question 61 of 61

Given the following code, which statements are true?

public interface Automobile { String describe(); }class FourWheeler implements Automobile{ String name; public String describe(){ return " 4 Wheeler " + name; }}class TwoWheeler extends FourWheeler{ String name; public String describe(){ return " 2 Wheeler " + name; }}

Select 3 correct optionsa An instance of TwoWheeler is also an instance of FourWheeler.  

b An instance of TwoWheeler is a valid instance of Automobile.  

c The use of inheritance is not justified, since TwoWheeler is not a FourWheeler.  

d The code will compile only if 'name' is removed from TwoWheeler.  

e The code will fail to compile.