Question: class Parent { public int x; } class Child extends Parent { public void doStuff() { System.out.println(I'm a child); } } class Main { public

class Parent {
public int x;
}
class Child extends Parent {
public void doStuff() {
System.out.println("I'm a child");
}
}
class Main {
public static void main(String[] args) {
Parent p1 = new Parent();
Child c1 = new Child();
Parent p2 = new Child();
p1.doStuff(); //Line 1
c1.doStuff(); //Line 2
p2.doStuff(); //Line 3
((Child)p2).doStuff(); //Line 4
}
}
Which line or lines of code below will cause compile errors? Line 1 Line 3 Line 1 Line 3 Line 4 Line 1 Line 2 Line 3 Line 4 Line 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
