41. |
Which of these data type value is returned by equals() method of String class?
|
||||||||
Answer:
Option (c) |
42. |
Which of these method of class String is used to remove leading and trailing whitespaces?
|
||||||||
Answer:
Option (b) |
43. |
What is the value returned by function compareTo() if the invoking string is greater than the string compared?
|
||||||||
Answer:
Option (c) |
44. |
At line number 2 in the following code, choose 3 valid data-type attributes/qualifiers among “final, static, native, public, private, abstract, protected”
1. public interface Status 2. { 3. /* insert qualifier here */ int MY_VALUE = 10; 4. }
|
||||||||
Answer:
Option (d) |
45. |
What will be the output of the following Java program?
final class A { int i; } class B extends A { int j; System.out.println(j + " " + i); } class inheritance { public static void main(String args[]) { B obj = new B(); obj.display(); } }
|
||||||||
Answer:
Option (d) |
46. |
What will be the output of the following Java program?
class A { int i; public void display() { System.out.println(i); } } class B extends A { int j; public void display() { System.out.println(j); } } class Dynamic_dispatch { public static void main(String args[]) { B obj2 = new B(); obj2.i = 1; obj2.j = 2; A r; r = obj2; r.display(); } }
|
||||||||
Answer:
Option (b) |
47. |
What will be the output of the following Java program?
class A { int i; void display() { System.out.println(i); } } class B extends A { int j; void display() { System.out.println(j); } } class inheritance_demo { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }
|
||||||||
Answer:
Option (c) |
48. |
What will be the output of the following Java program?
class A { int i; } class B extends A { int j; void display() { super.i = j + 1; System.out.println(j + " " + i); } } class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }
|
||||||||
Answer:
Option (c) |
49. |
What will be the output of the following Java program?
class A { public int i; public int j; A() { i = 1; j = 2; } } class B extends A { int a; B() { super(); } } class super_use { public static void main(String args[]) { B obj = new B(); System.out.println(obj.i + " " + obj.j) } }
|
||||||||
Answer:
Option (a) |
50. |
What will be the output of the following Java code?
class A { public int i; private int j; } class B extends A { void display() { super.j = super.i + 1; System.out.println(super.i + " " + super.j); } } class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }
|
||||||||
Answer:
Option (d) |