Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Look at the following code. Which line will cause a compiler error? Line 1 publi

ID: 3836136 • Letter: L

Question

Look at the following code. Which line will cause a compiler error? Line 1 public class ClassA Line 2 {Line 3 public ClassA () {} Line 4 public int method1 (int a) {} Line 5 public final int method2(double b) {} Line 6} Line 7 public ClassB extends ClassA Line 8 {Line 9 public ClassB () {} Line 10 public int method 1 (int b) {} Line 11 public int method2 (double c) {} Line 12} What is wrong with the following code? public class ClassB extends ClassA {public Class B () {int init = 10; super(40);}}

Explanation / Answer

23.public class ClassA{
public ClassA(){}
public final int method1(int a){}
public double method2(int b){}

}
class ClassB extends ClassA{
public ClassB(){}
  
public int method1(int b){}// this line will throw compilation error as final methods can not be overriden //in child class,. this method in parent class is final, so cant be overriden
public double method2(double c){}
  
  
}

24.

class ClassB extends ClassA{
public ClassB(){}

int init=10;

super(40);// this line will throw compilation error as parent class A doesnt have parametrized constructor in //it, so, it will not be able to make call to parent class constructor.
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote