Java Online Exam-Quiz2

Please enter your email:

1. Find the output of the following program.

public class Solution{

public static void main(String[] args)

{

byte x = 127;

x++;

x++;

System.out.print(x);       }}

 
 
 
 

2.

In which of the following is toString() method defined?

 
 
 
 

3.

Automatic type conversion is possible in which of the possible cases?

 
 
 
 

4. Find the output of the following code.

Public class Solution{

Public static void main(String… argos){

Int x = 5;

x * = (3 + 7);

System.out.println(x);

 
 
 
 

5.

When is the finalize() method called?

 
 
 
 

6.

What is the size of float and double in java?

 
 
 
 

7. Find the output of the following program.

public class Solution{
       public static void main(String[] args){
               int[]  x = {120, 200, 016};
               for(int i = 0; i < x.length; i++){
                        System.out.print(x[i] + “ “);
               }                   
       }
}
 
 
 
 

8. How many times will “Interviewbit” be printed.

Int count = 0;
do{
  System.out.println(“Interviewbit”);
  count++;
} while(count < 10);
 
 
 
 

9.

Select the valid statement to declare and initialize an array.

 
 
 
 

10. Number of primitive data types in Java are?

 
 
 
 

11.

Find the output of the following code.

if(1 + 1 + 1 + 1 + 1 == 5){
  System.out.print(“TRUE”);
}
else{
  System.out.print(“FALSE”);
}
 
 
 
 

12.

Where does the system stores parameters and local variables whenever a method is invoked?

 
 
 
 

13. What does the following string do to given string str1.

String str1 = “Interviewbit”.replace(‘e’,’s’);

String str1 = “Interviewbit”.replace(‘e’,’s’);

 
 
 
 

14. Find the value of A[1] after execution of the following program.

int[] A = {0,2,4,1,3};
for(int i = 0; i < a.length; i++){
    a[i] = a[(a[i] + 3) % a.length];
}
 
 
 
 

15. How many objects will be created in the following?

String a = new String(“Interviewbit”);

String b = new String(“Interviewbit”);

Strinc c = “Interviewbit”;

String d = “Interviewbit”;

 
 
 
 

16. Find the output of the following code.

Public class Solution{
         Public static void main(String args[]){
                 Int i;
                 for(i = 1; i < 6; i++){ 
                     if(i > 3) continue;
                 }
                 System.out.println(i);
          }
}
 
 
 
 

Question 1 of 16

error: Content is protected !!