JAVA QUIZ
1 .
What is not the use of “this” keyword in Java?

Correct Answer : Option (C)

Passing itself to method of the same class
  Show Answer
2 .
What would be behaviour if the constructor has a return type?

Correct Answer : Option (A)

Compilation error
  Show Answer
3 .
What is the process of defining two or more methods within same class that have same name but different parameters declaration?

Correct Answer : Option (B)

method overloading
  Show Answer
4 .
What is the process of defining a method in terms of itself, that is a method that calls itself?

Correct Answer : Option (D)

Recursion
  Show Answer
5 .
What will be the output of the following Java code?
 
    class test 
    {
        int a;
        int b;
        void meth(int i , int j) 
        {
            i *= 2;
            j /= 2;
        }          
    }    
    class Output 
    {
        public static void main(String args[])
        {
            test obj = new test();
	    int a = 10;
            int b = 20;             
            obj.meth(a , b);
            System.out.println(a + " " + b);        
        } 
    }

Correct Answer : Option (A)

10 20
  Show Answer
6 .
Which of these is used to access a member of class before object of that class is created?

Correct Answer : Option (C)

static
  Show Answer
7 .
What is the process by which we can control what parts of a program can access the members of a class?

Correct Answer : Option (D)

Encapsulation
  Show Answer
8 .
What will be the output of the following Java code?
 
    class static_out 
    {
        static int x;
 	static int y;
        void add(int a, int b)
        {
            x = a + b;
            y = x + b;
        }
    }    
    public class static_use 
    {
        public static void main(String args[])
        {
            static_out obj1 = new static_out();
            static_out obj2 = new static_out();   
            int a = 2;
            obj1.add(a, a + 1);
            obj2.add(5, a);
            System.out.println(obj1.x + " " + obj2.y);     
        }
   }

Correct Answer : Option (A)

7 9
  Show Answer
9 .
Which of these method of String class can be used to test to strings for equality?

Correct Answer : Option (D)

equals()
  Show Answer
10 .
What will be the output of the following Java program?
 
    class string_class 
    {
        public static void main(String args[])
        {
            String obj = "I LIKE JAVA";   
            System.out.println(obj.charAt(3));
        } 
    }

Correct Answer : Option (A)

I
  Show Answer