Logo

Java Questions Set 220:

Quiz Mode

Predict the output of the following Java code.

1
2
3

Solution:

Which method can be defined only once in a class?

1
2
3
4

Solution:

getproperty() methods are used to retrieve the elements in properties object at a specific location  

1
2

Solution:

Which of the given choices is the possible output?

1
2

Solution:

class abekus {

public static void main (String[] args) {

int a=50,b=70,c=65;

if((a>c) || !(++b>c)){

System.out.println("Inside if block");

}

else

  System.out.println("Outside if block");

}

}

Solution:

public class output{

public static void main(String args[]){

int a=100;

int b=120;

int result=0;

result= a + ++b + 1 + a++ + 30 + ++b + b;

System.out.println(result);

 }

}

1
2
3
4

Solution:

Predict the output of the following Java code:

1
2
3
4

Solution:

 Statement 1-RuntimeException is thrown by every method of Runtime class 

 Statement 2- SecurityException is thrown by every method of Runtime class 

 Statement 3- SystemException is thrown by every method of Runtime class 

1
2
3
4

Solution:

Predict the output of the following Java code:

import java.util.*;

import java.util.stream.IntStream;

class Abekus {

public static void main(String[] args) {

IntStream i = IntStream.of(2, 6, 10, 46);

boolean j = i.allMatch(n -> n % 4 == 2);

System.out.println(j);

}

}

1
2
3

Solution:

Which of the following statements about the replace() method is correct?

1
2
3
4

Solution: