Tag: technology

Questions Related to technology

class Abc { int i=initialize(369); int j=initialize(); public int initialize() { return 318; } public void initialize(int i) { this.i=i; } public static void main(String a[]) { Abc abc=new Abc(); System.out.println("i="+abc.i); abc.initialize(369); System.out.println("after i="+abc.i); System.out.println("j="+abc.j); } }

  1. Error: Non static method intialize cannot accessed from static context main

  2. Error: Method initialize is already defined

  3. i=0 after i=369 j=318

  4. Error: incompatible types


Correct Option: D

class Abc { static { System.out.print("Static block "); display(); } public void display() { System.out.print("Display block "); } public static void main(String a[]) { System.out.print("Starting of Main block "); Abc abc=new Abc(); System.out.print("In the Main block "); abc.display(); } }

  1. Starting of Main block Static block In the Main block Display block

  2. Static block Display block Starting of Main block In the Main block Display block

  3. Error: Non static method cannot accessed from static context

  4. Starting of Main block In the Main block Display block


Correct Option: B

Given: classA {} class B extends A {} class C extends A {} class D extends B {} Which three statements are true? (Choose three.)

  1. The type List is assignable to List.

  2. The type List is assignable to List>.

  3. The type List is assignable to List extends B>.

  4. The type List extends A> is assignable to List.

  5. The type List is assignable to any List reference.

  6. The type List extends B> is assignable to List extends A>.


Correct Option: B,C,F