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 3 of 8

Q21.
What is the output of this program?
    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)     
        }
   }
Discuss
Answer: (a).1 2
Discuss
Answer: (b).Double inheritance
Q23.
Using which of the following, multiple inheritance in Java can be implemented?
Discuss
Answer: (a).Interfaces
Q24.
All classes in Java are inherited from which class?
Discuss
Answer: (d).java.lang.Object
Q25.
In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?
Discuss
Answer: (b).Private
Q26.
If super class and subclass have same variable name, which keyword should be used to use super class?
Discuss
Answer: (a).super
Q27.
Static members are not inherited to subclass.
Discuss
Answer: (b).False
Q28.
Which of the following is used for implementing inheritance through an interface?
Discuss
Answer: (d).implements
Q29.
Which of the following is used for implementing inheritance through class?
Discuss
Answer: (c).extends
Q30.
What would be the result if a class extends two interfaces and both have a method with same name and signature?
Discuss
Answer: (b).Compile time error
Page 3 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!