Logo

Java Questions Set 232:

Quiz Mode

How many public classes can be present in a java source file?

1
2
3
4

Solution:

What is the output of the following Java code?

1
2
3
4

Solution:

Which of these methods of the StringBuffer class is used to find the length of the current character sequence?

1
2
3
4

Solution:

Which of the following is a type of polymorphism in Java?

1
2
3
4

Solution:

float x=12.8;


 

Which of the following is a correct way to convert the value of x to an integer and store the result in the variable y?

1
2
3
4

Solution:

public class abekus{

public static void main(String[] args){

 int a = 5;

 a +=5;

 switch(a){

  case 5: System.out.print("5"); break;

  case 10: System.out.print("10");

  default: System.out.print("0");

 }

}

}

1
2
3
4

Solution:

Statement 1- Vector is an interface

Statement 2- Iterable is an Interface

 Statement  3- List is a class

 Statement  4- vector is an Interface

1
2
3
4
5

Solution:

What will be the output of the following Java code?

class Output

{

public static void main(String args[])

{

Double y = new Double(257.57812);

Double i = new Double(257.578123456789);

try

{

int x = i.compareTo(y);

System.out.print(x);

}

catch(ClassCastException e)

{

System.out.print("Exception");

}

}

}

1
2
3
4

Solution:

// Predict the output

import java.util.Scanner;

class Main

{

 public static void main (String[] args)

 {

 int arr[] = {10, 20, 30, 40};

 int a = 50;

 call(a, arr);

 System.out.println(a);

 System.out.println(arr[0]);

 System.out.println(arr[1]);

 }

 public static void call(int a, int arr[])

 {

 a = a + 2;

 arr[0] = 100;

 arr[1] = 200;

 }

}

1
2
3
4

Solution:

What is the output of the following java program?

class Abekus {

 public void show() {

 System.out.println("Abekus::show() called");

 }

}

class Derived extends Abekus {

 public void show() {

 System.out.println("Derived::show() called");

 }

}

public class Main {

 public static void main(String[] args) {

  Abekus a = new Derived();;

  a.show();

 }

}

1
2
3
4

Solution: