Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Java
lang="java">package Pack1;

abstract class A
{
  int i;
  public A(int i)
  {
    this.i=i;
    System.out.println(this.i);
  }
}

class B extends A() //Syntax error on token "extends",@ expected after this token
{ //Syntax error on token "{", delete this token

  public B(int a) //syntax error on token "public" delete this token. And Syntax error 
                  on token "int", delete this token
  {
    super(a);
  }
} //Syntax error on token "}", delete this token

public class Test3 
{
  public static void main(String[] args) 
  {
    B b1=new B(7);
  }
}


What I have tried:

In the above commented line I am getting error. Please suggest a solution
Posted
Updated 29-Jul-18 8:23am
v4
Comments
Patrice T 26-Jul-18 14:50pm    
And you plan to tell us the error message and position ?
radhikay 26-Jul-18 15:03pm    
Position I have commented.
Patrice T 26-Jul-18 19:41pm    
And you have an error message ?
Richard Deeming 27-Jul-18 9:00am    
If you want us to help you fix an error, then you need to tell us what the error is! "Getting error" is not enough information for anyone to help you.

Click the green "Improve question" link and add the full details of the error(s) to your question.
radhikay 29-Jul-18 14:10pm    
I have update the questions with the error description, Please check it

1 solution

It is extremely important to learn the syntxt of the language you are using!!!
Java Inheritance[^]
 
Share this answer
 
Comments
radhikay 26-Jul-18 15:02pm    
I have learnt inheritance. Please tell me what is the error meaning
Kornfeld Eliyahu Peter 26-Jul-18 15:06pm    
Obviously you not even read the page I sent you... otherwise you would see the obvious syntax error you made there...
radhikay 26-Jul-18 15:09pm    
No Sir, It is not about the page I am talking about. I know what is inheritance I have read it before I post this question. Really I am not able to find what is the error. Even the eclipse is not suggesting me any fix
radhikay 26-Jul-18 15:11pm    
I am a beginner to this, so feeling bit difficult
Dave Kreskowiak 29-Jul-18 14:41pm    
Hint: In your code and looking at the page that Kornfeld linked to, do you see any instance of parenthesis after the name of the class your extending?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900