Logo

Java Questions Set 234:

Quiz Mode

How many access modifiers are there in Java?

1
2
3
4

Solution:

Which class is related to all the exceptions that cannot be caught?

1
2
3
4

Solution:

Predict the output of the following Java program.

1
2
3
4

Solution:

What is the output of the following Java code?

class rightshift_operator

{

public static void main(String args[])

{

int x;

x = 10;

x = x >> 1;

System.out.println(x);

}

}

1
2
3
4

Solution:

PollFirst() is used to remove the first element

1
2
3
4
5

Solution:

Predict the output of the following Java code:

class Abekus {
public static void main(String args[])
{
String s = "Welcome to Abekus";
char a[] = new char[8];
s.getChars(0, 6, a, 0);
System.out.println(a);
}
}

1
2
3
4

Solution:

Which of   the following is true?

1
2
3
4

Solution:

void start() {  
   A a = new A();
   B b = new B();
   a.s(b);  
   b = null; /* Line 5 */
   a = null;  /* Line 6 */
   System.out.println("start completed"); /* Line 7 */
}

When is the B object, created in line 3, eligible for garbage collection?

1
2
3
4

Solution:

What will be the code output?.

package com.pk3;

public class Abekus{

 protected void m1()

{

 System.out.println("Protected method has been called.");

}

}

 

package com.pkg2;

import com.pk3.Abekus;

public class def extends Abekus {

 public static void main(String args[]) {

  def d=new def();

  d.m1();

}

}

Note: Two classes are there.class def inherit the class Abekus.

1
2
3
4

Solution: