Submitted by c-admin on Fri, 05/31/2019 - 06:28
Expression (s instanceof java.util.Date) will return false if 's' was declared as a variable of class java.lang.String.
Select 1 option
A. True
B. False
Submitted by c-admin on Fri, 05/31/2019 - 06:27
Given the following class definitions, the expression
(obj instanceof A) && ! (obj instanceof C) && ! (obj instanceof D)
correctly identifies whether the object referred to by obj was created by instantiating class B rather than classes A, C and D?
class A {}
class B extends A {}
class C extends B {}
class D extends C {}
Select 1 option
A. True
B. False
Submitted by c-admin on Fri, 05/31/2019 - 06:26
Which of the following statements are true?
Select 1 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
Submitted by c-admin on Fri, 05/31/2019 - 06:21
Given the following class definitions and declaration:
class A {}
class B extends A {}
class C extends B {}
class D extends C {}
D d = new D();
the expression (d instanceof A) will return true.
Select 1 option
A. True
B. False
Submitted by c-admin on Fri, 05/31/2019 - 06:20
Which letters will be printed when the following program is run?
public class TestClass{
public static void main(String args[]){
B b = new C();
A a = b;
if (a instanceof A) System.out.println("A");
if (a instanceof B) System.out.println("B");
if (a instanceof C) System.out.println("C");
if (a instanceof D) System.out.println("D");
}
}class A { }
class B extends A { }
class C extends B { }
class D extends C { }
Select 3 options
A. A will be printed.
B. B will be printed.
C. C will be printed.
D. D will be printed.
Pages