Vidyalelo
Java Programming · all questions

Inheritence
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

86

Questions

5/5

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following Java program?
class A 
{
int i;
int j;
     A() 
     {
         i = 1;
         j = 2;
     }
}
class Output 
{
     public static void main(String args[])
     {
          A obj1 = new A();
          A obj2 = new A();
    System.out.print(obj1.equals(obj2));
     }
}

Select an option to see the answer and solution.

What would be the result if a class extends two interfaces and both have a method with same name and signature? Lets assume that the class is not implementing that method.

Select an option to see the answer and solution.

Which of the following is used for implementing inheritance through class?

Select an option to see the answer and solution.

In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?

Select an option to see the answer and solution.

What is not type of inheritance?

Select an option to see the answer and solution.

What will be the output of the following Java code?
class A 
{
    public int i;
    public int j;
    A() 
   {
        i = 1;
        j = 2;
}
}    
class B extends A 
{
    int a;
B() 
    {
        super();
    } 
}    
class super_use 
{
    public static void main(String args[])
    {
        B obj = new B();
        System.out.println(obj.i + " " + obj.j)     
    }
}

Select an option to see the answer and solution.