Question
public class XYZ { private int myNum; public XYZ() { myNum=0; } public XYZ(int n1) { myNum=n1; } } public class ABC extends XYZ {
public class XYZ { private int myNum; public XYZ() { myNum=0; } public XYZ(int n1) { myNum=n1; } }
public class ABC extends XYZ { private int num2; public ABC() { myNum=0; num2=0; } pubilc ABC(int n1) { myNum=n1; num2=n1*2; } }
class Main { public static void main(String[] args) { ABC myABC = new ABC(); } } | public class XYZ { private int myNum; public XYZ() { myNum=0; } public XYZ (int n1) { myNum = n1; } } public class ABC : XYZ { private int num2; public ABC() { myNum=0; num2=0; } public ABC (int n1) { myNum = n1; num2 = n1*2; } } class MainClass { public static void Main (string[] args) { ABC myABC= new ABC(); } } |
Question 4 options:
| myNum is defined as private in XYZ and as such is inaccessable in ABC. |
| class ABC cannot have private attributes because it's inheriting from XYZ |
| class ABC is not allowed to inherit from class XYZ |
| You cannot instantiate an object of type ABC, you can only instantiate objects of type XYZ |
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