Tag: programming languages

Questions Related to programming languages

  1. final

  2. static

  3. native

  4. public

  5. private

  6. abstract


Correct Option: A,B,D
Explanation:

Explanation: In Java, an interface can only have public abstract methods and public static final fields. Therefore, on line 12, we can have only public, static, and final keywords. The correct answer options are D) public.

Option A) final - This option is correct because final keyword can be used only with the variables and methods

Option B) static - This option is correct because static keyword can be used with an interface.

Option C) native - This option is incorrect because native keyword is not allowed.

Option D) public - This option is correct because public keyword can be used

Option E) private - This option is incorrect because private keyword is not allowed

Option F) abstract - This option is incorrect because abstract keyword is not allowed.

Therefore, the correct options are B) static, D) public, and A) final.

  1. foreach(x) System.out.println(z);

  2. for(int z : x) System.out.println(z);

  3. while( x.hasNext()) System.out.println( x.next());

  4. for( int i=0; i< x.length; i++ ) System.out.println(x[i]);


Correct Option: B,D
  1. The instance gets garbage collected.

  2. The code on line 33 throws an exception.

  3. The code on line 35 throws an exception.

  4. The code on line 31 throws an exception.

  5. The code on line 33 executes successfully.


Correct Option: B,C,E