I have written a super class called Parent.java and it was extended to create a subclass called Child.java.
The super class can be compiled properly, but when the child is compiled an error is poped up.
//parent class
package abc;
public class Parent{
protected int st_marks=180;
}
//child class
package def;
import abc.Parent;
public class Child extends Parent{
protected double avg;
avg = st_marks/2;
public void display(){
System.out.println("Average ="+avg);
}
}
The error that I get when the child class is compiled is
Child.java:5: error: <identifier> expected
avg = st_marks/2;
^
1 error
Looking forward to receive a prompt respond.