Easy Tutorial
For Competitive Exams

Which is true about a method-local inner class?

It must be marked final.
It can be marked abstract.
It can be marked public.
It can be marked static.
Explanation:

Option B is correct because a method-local inner class can be abstract, although it means a subclass of the inner class must be created if the abstract class is to be used (so an abstract method-local inner class is probably not useful).

Option A is incorrect because a method-local inner class does not have to be declared final (although it is legal to do so).

Options C and D are incorrect because a method-local inner class cannot be made public (remember-you cannot mark any local variables as public), or static.

Additional Questions

What will be the output of the program?

public class Switch2 {

final static short x = 2;

public static int y = 0;

public static void main(String [] args) {

for (int z=0; z < 4; z++) {

switch (z) {

case x:

System.out.print("0 ");

default:

System.out.print("def ");

case x-1:

System.out.print("1 ");

break;

case x-2:

System.out.print("2 ");

}}}}

Answer

What will be the output of the program?

class Base {

Base() {

System.out.print("Base");

}

}

public class Alpha extends Base {

public static void main(String[] args) {

new Alpha(); / * Line 12 * /

new Base(); / *Line 13 * /

}

}

Answer

Which collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence?

Answer

What will be the output of the program?

for(int i = 0; i < 3; i++) {

switch(i) {

case 0: break;

case 1: System.out.print("one ");

case 2: System.out.print("two ");

case 3: System.out.print("three ");

}

}

System.out.println("done");

Answer

What will be the output of the following program on GCC?

int main(){

static int c=5;

printf("c=%d",c--);

if(c)

main();

return 0;

}

Answer

What is the base class for all Exception ?

Answer

In SQL, which command is used to remove a stored function from the database?

Answer

bus is a / an

Answer

Form of code that uses more than one process and processor, possibly of different type, and that may on occasions have more than one process or processor active at the same time, is known as

Answer

Which of the following system program forgoes the production of object code to generate absolute machine code and load it into the physical main storage location from which it will be executed immediately upon completion of the assembly?

Answer
Share with Friends
Privacy Copyright Contact Us