Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Consider the following java program to answer the questions given below [C02, C3 based on your understanding of inheritance and polymorphism. class Superclass
1. Consider the following java program to answer the questions given below [C02, C3 based on your understanding of inheritance and polymorphism. class Superclass { protected int x = 0; public SuperClass(int x) { } this.x = x; protected final void increment () { } x++; private void add(int y) { x += y; } public void display() { Marks: 3+3+2+4] } } System.out.println(x); public class SubClass extends SuperClass { public SubClass(int x) { } } super(x); public void display() { } increment(); super.display(); public static void main(String[] args) { SuperClass sc = new SuperClass(3); } sc.display(); sc = new SubClass(3); sc.display(); a) List the name of all methods that subclasses of Super Class inherit. b) List the name of all methods that are visible in subclasses of SuperClass (in other words, methods that can be called directly). c) List the name of all methods that may NOT be overridden by any subclasses of SuperClass. d) What gets displayed on the screen when the main method SubClass is executed?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started