• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

please help me

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public final class Flaw
{
int age=7;
String name="Bala";
}
class Dflaw extends Flaw
{
public int method()
{
System.out.println("Enter the age=" + age);
System.out.println("Enter the String="

+name);
}}
public static void main(String[] args)
{
Flaw f=new Flaw;
f.age;
f.name;
}
I do not know what is wrong in this ..please post
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the compiler tells you what is wrong.



are there some parts you do not understand?
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy, cowboys!

First, class Flaw must not be final. Otherwise it cannot be extended.

Second, there are several brackets }} at the wrong places.
To avoid this, use propper indentation of your code. The indentation is visible on the Ranch only if you use the - tag when posting. Do this.

Third: method method is declared to return an int but doesn't.

Number four, with f.name and f.age you are referring to variables but you don't assign anything to it. This is also not possible.

Number five: Your user name should not be in uppercase letters.

By the way: The compiler only shows one error in the first place (15: 'class' or 'interface' expected).
This cryptic message comes from one of the misplaced brackets in the line before. If you remove this error and resave, compiler will tell you more errors.


Yours,
Bu.
reply
    Bookmark Topic Watch Topic
  • New Topic