• Post Reply Bookmark Topic Watch Topic
  • New Topic

compiler Errors in inheritance  RSS feed

 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I am getting compiler errors at non static initialization of difficultyLevel as "Illegal modifier for the variable difficultyLevel; only final is permitted"
Why am I getting this error ?

another compiler error I am getting is at invoking printDifficultyLevel(). "The method printDifficultyLevel() is undefined for the type ExtendTestSub" - If a method of super class is used inn sub class, is it not allowed ? Why am I getting this error ?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nirjari patel wrote:


I am getting compiler errors at non static initialization of difficultyLevel as "Illegal modifier for the variable difficultyLevel; only final is permitted"
Why am I getting this error ?


Simply, local variable can't be declared as private, protected. or public -- as mentioned in the error message.

Henry
 
James X Peterson
Whizlabs Java Support
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nirjari patel wrote:[code=java]

another compiler error I am getting is at invoking printDifficultyLevel(). "The method printDifficultyLevel() is undefined for the type ExtendTestSub" - If a method of super class is used inn sub class, is it not allowed ? Why am I getting this error ?


you will not get error by calling printDifficultyLevel() method . Once you try by removing block for variable difficultyLevel in ExtendTestSub class

Regards,
James
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!