adplus-dvertising

Welcome to the Inheritance MCQs Page

Dive deep into the fascinating world of Inheritance with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Inheritance, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Inheritance, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Inheritance. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Inheritance. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Inheritance MCQs | Page 5 of 8

Q41.
What is the output of this program?
    class A 
    {
        int i;
        public void display() 
        {
            System.out.println(i);
        }    
    }    
    class B extends A 
   {
        int j;
        public void display() 
        {
            System.out.println(j);
        } 
    }    
    class Dynamic_dispatch 
   {
        public static void main(String args[])
        {
            B obj2 = new B();
            obj2.i = 1;
            obj2.j = 2;
            A r;
            r = obj2;
            r.display();     
        }
   }

a.

1

b.

2

c.

3

d.

4

Discuss
Answer: (b).2
Q42.
What is the output of this program?
    class Output 
    {
        public static void main(String args[])
        {
             Object obj = new Object();
	     System.out.print(obj.getclass());
        }
    }
Discuss
Answer: (c).class java.lang.Object
Q43.
What is the output of this program?
   class A 
   {
        int i;
	int j;
        A() 
        {
            i = 1;
            j = 2;
        }
   }
   class Output 
   {
        public static void main(String args[])
        {
             A obj1 = new A();
	     System.out.print(obj1.toString());
        }
   }
Discuss
Answer: (c).String associated with obj1
Q44.
What is the output of this program?
    class A 
    {
        int i;
        void display() 
        {
            System.out.println(i);
        }
    }    
    class B extends A 
    {
        int j;
        void display() 
        {
            System.out.println(j);
        }
    }    
    class method_overriding 
    {
        public static void main(String args[])
        {
            B obj = new B();
            obj.i=1;
            obj.j=2;   
            obj.display();     
        }
   }
Discuss
Answer: (c).2
Q45.
What is the output of this program?
    class A 
    {
        public int i;
        protected int j;
    }    
    class B extends A 
    {
        int j;
        void display() 
        {
            super.j = 3;
            System.out.println(i + " " + j);
        }
    }    
    class Output 
    {
        public static void main(String args[])
        {
            B obj = new B();
            obj.i=1;
            obj.j=2;   
            obj.display();     
        }
   }
Discuss
Answer: (a).1 2
Q46.
What are the features of an Object Oriented Programming (OOPs)?
Discuss
Answer: (d).All of the above
Q47.
What are the features reused using Inheritance in Java?
Discuss
Answer: (d).All of the above
Q48.
The class that is being inherited or subclassed is called ___.
Discuss
Answer: (b).Superclass
Q49.
The class that inherits an already defined class is called ___.
Discuss
Answer: (a).Subclass
Q50.
Java language supports ___ type of inheritance.
Discuss
Answer: (b).Multi-Level Inheritance
Page 5 of 8

Suggested Topics

Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!