Tag: technology

Questions Related to technology

What is the result of compiling and running this program? class Clove{ void quality(Clove m){ System.out.println("Clove is nice"); } } class Mint extends Clove{ void quality(Mint c){ System.out.println("Mint is ok"); } } class Sage extends Mint{ void quality(Sage h){ System.out.println("Sage is average"); } } public class Test{ public static void main(String[] args){ Clove h = new Sage(); Mint c = new Sage(); c.quality(h); } }

  1. prints "Clove is nice"

  2. prints "Mint is ok"

  3. prints "Sage is average"

  4. Class cast Exception at runtime.


Correct Option: A

Given classes defined in two different files: 1. package util; 2. public class BitUtils { 3. public static void process(byte[]) { /* more code here */ } 4. } 1. package app; 2. public class SomeApp { 3. public static void main(String[] args) { 4. byte[] bytes = new byte[256]; 5. // insert code here 6. } 7. } What is required at line 5 in class SomeApp to use the process method of BitUtils?

  1. process(bytes);

  2. BitUtils.process(bytes);

  3. util.BitUtils.process(bytes);

  4. SomeApp cannot use methods in BitUtils.

  5. import util.BitUtils.*; process(bytes);


Correct Option: C
  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