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

Q71.
A Superclass reference can refer to a Subclass Object without casting. State TRUE or FALSE.
Discuss
Answer: (a).TRUE
Q72.
A superclass reference can not be used to invoke a method or variable of the subclass. State TRUE or FALSE.
Discuss
Answer: (a).TRUE
Q73.
A subclass object can be used to invoke (call) a method or property of the superclass. State TRUE or FALSE.
Discuss
Answer: (a).TRUE
Q74.
What is the output of the below Java program on the references of Superclass and Subclass?
class Food
{
  void show()
  {
    System.out.print("FOOD ");
  }
}
class Bread extends Food
{
  void toast()
  {
    System.out.print("TOASTED ");
  }
}
public class Inheritance5
{
  public static void main(String[] args)
  {
    Food foo = new Food();
    foo.show();
    Food foo2 = new Bread();
    foo2.show();
    Bread br = new Bread();
    br.toast();
    br.show();
  }
}
Discuss
Answer: (b).FOOD FOOD TOASTED FOOD
Q75.
What is the output of the below Java program using Inheritance?
class Furniture
{
  void show()
  {
    System.out.println("Made of Wood. ");
  }
}
class Sofa extends Furniture
{
  void addCushion()
  {
    System.out.println("Added. ");
  }
}
public class Inheritance6
{
  public static void main(String[] args)
  {
    Furniture fur = new Sofa();
    fur.addCushion();
  }
}
Discuss
Answer: (d).Compiler error
Page 8 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!