Essay on The Republic Day | Republic Day Essay in English
[ Festival Ganesh Chaturthi Essay in English for Students and Children ] [ Essay on my favourite freedom fighter ] ⚔️ [ दुर्गा पूजा पर निबंध (Durga Puja Hindi Essay) ]
[Essay On 75th Independence Day Of India] [Azadi Ka Amrit Mahotsav Essay in English]

Which two statements are true about wrapper or&n

Loading

Practice Java.lang Class –

Which two statements are true about wrapper or String classes?

  1. If x and y refer to instances of different wrapper classes, then the fragment x.equals(y) will cause a compiler failure.
  2. If x and y refer to instances of different wrapper classes, then x == y can sometimes be true.
  3. If x and y are String references and if x.equals(y) is true, then x == y is true.
  4. If xy, and z refer to instances of wrapper classes and x.equals(y) is true, and y.equals(z) is true, then z.equals(x) will always be true.
  5. If x and y are String references and x == y is true, then y.equals(x) will be true.

What will be the output of the program (in jdk1.6 or above)?

Loading

Practice Java.lang Class –

What will be the output of the program (in jdk1.6 or above)?

public class BoolTest {    
public static void main(String [] args) {
Boolean b1 = new Boolean("false");
boolean b2;
b2 = b1.booleanValue();
if (!b2) {
b2 = true;
System.out.print("x");
}
if (b1 & b2) /* Line 13 */ {
System.out.print("y ");
}
System.out.println("z");
}
}

 

What will be the output of the program?


			  		

Loading

Practice Java.lang Class –

What will be the output of the program?

public class BoolTest  {     
public static void main(String [] args) {
int result = 0;
Boolean b1 = new Boolean("TRUE");
Boolean b2 = new Boolean("true");
Boolean b3 = new Boolean("tRuE");
Boolean b4 = new Boolean("false");
if (b1 == b2) /* Line 10 */
result = 1;
if (b1.equals(b2) ) /* Line 12 */
result = result + 10;
if (b2 == b4) /* Line 14 */
result = result + 100;
if (b2.equals(b4) ) /* Line 16 */
result = result + 1000;
if (b2.equals(b3) ) /* Line 18 */
result = result + 10000;
System.out.println("result = " + result);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Java.lang Class –

What will be the output of the program?

public class WrapTest {     
public static void main(String [] args) {
int result = 0;
short s = 42;
Long x = new Long("42");
Long y = new Long(42);
Short z = new Short("42");
Short x2 = new Short(s);
Integer y2 = new Integer("42");
Integer z2 = new Integer(42);
if (x == y) /* Line 13 */
result = 1;
if (x.equals(y) ) /* Line 15 */
result = result + 10;
if (x.equals(z) ) /* Line 17 */
result = result + 100;
if (x.equals(x2) ) /* Line 19 */
result = result + 1000;
if (x.equals(z2) ) /* Line 21 */
result = result + 10000;
System.out.println("result = " + result);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Java.lang Class –

What will be the output of the program?

interface Count {    
short counter = 0;
void countUp();
}
public class TestCount implements Count {
public static void main(String [] args) {
TestCount t = new TestCount();
t.countUp();
}
public void countUp() {
for (int x = 6; x>counter; x--, ++counter) /* Line 14 */ {
System.out.print(" " + counter);
}
}
}

 

Which two statements are true for any concrete class implementing t

Loading

Practice Java.lang Class –

Which two statements are true for any concrete class implementing the java.lang.Runnable interface?

  1. You can extend the Runnable interface as long as you override the public run() method.
  2. The class must contain a method called run() from which all code for that thread will be initiated.
  3. The class must contain an empty public void method named run().
  4. The class must contain a public void method named runnable().
  5. The class definition must include the words implements Threads and contain a method called run().
  6. The mandatory method must be public, with a return type of void, must be called run(), and cannot take any arguments.

interface Base {    
boolean m

Loading

Practice Java.lang Class –

interface Base {    
boolean m1();
byte m2(short s);
}

Which two code fragments will compile?

  1. interface Base2 implements Base { }

     

  2. abstract class Class2 extends Base { 
    public boolean m1(){
    return true;
    }
    }

     

  3. abstract class Class2 implements Base {}

     

  4. abstract class Class2 implements Base { 
    public boolean m1(){
    return (7 > 4);
    }
    }