Java Quiz

0 votes, 0 avg
363

Java Questions

1 / 15

1. Which of the following is not an OOPS concept in Java?

2 / 15

2. What will be the output of the following Java program?

        class Output 

        {

             public static void main(String args[]) 

            {

                double x = 2.0;  

                double y = 3.0;

                double z = Math.pow( x, y );

                System.out.print(z);

            }

        }

3 / 15

3. Find the output of the following code.

        class ternary_operator 

        {

            public static void main(String args[]) 

            {        

                 int x = 3;

                 int y = ~ x;

                 int z;

                 z = x > y ? x : y;

                 System.out.print(z);

            } 

        }

4 / 15

4. What is the syntax for java main method?

5 / 15

5. Which environment variable is used to set the java path?

6 / 15

6. What is an assignment statement?

7 / 15

7. Which constructor creates an empty string buffer with the specified capacity as length.

8 / 15

8. 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];
}

9 / 15

9. Which of these statements is incorrect about Thread?

10 / 15

10.  The following program is an example for?

class Student{
int id;
String name;

void display(){System.out.println(id+" "+name);}

public static void main(String args[]){
Student s1=new Student();
Student s2=new Student();
s1.display();
s2.display();
}
} 

11 / 15

11. Find the output of the following program.

class output {
public static void main(String args[]) 
            {
                double a, b,c;
                a = 3.0/0;
                b = 0/4.0;
                c=0/0.0;
    	    System.out.println(a);              System.out.println(b);               System.out.println(c);
            } 
        }

12 / 15

12. What will be the output of the following Java program?

        class recursion 

{

int func (int n)

{

int result;

if (n == 1)

return 1;

result = func (n - 1);

return result;

}

}

class Output

{

public static void main(String args[])

{

recursion obj = new recursion() ;

System.out.print(obj.func(5));

}

}


                            

13 / 15

13. Choose the appropriate data type for this field: isSwimmer

14 / 15

14. Which of these keywords is used to prevent content of a variable from being modified?

15 / 15

15. What is Recursion in Java?

Your score is

The average score is 36%

0%