• Post Reply Bookmark Topic Watch Topic
  • New Topic

about class  RSS feed

 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when a class extends an other class .Both class i should create them (on netbeans )i should mouse over the package of my exercise after right click on it and it has a menu first it says new i click on it after it has folder (down of it has the Java class ) .So what i should do is to create with this way to class right? it doesnt matter if a class extends an another?(i mean maybe it doesnt want to be with that way )
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget about NetBeans for the time being. That is only a tool to make things faster, and I suspect for many beginners it does more to confuse them than help. Remember that all classes extend another class implicitly, even if you don't say extends. That class is called Object.
I don't remember offhand how to create a class on NetBeans.

If you want ClassB to extend ClassA, you must be sure that whatever ClassB represents is a special kind of whatever ClassA represents. Example:-The case with Taxi can be awkward, because you need to think about how you calculate the charge for passengers, which you would not do for an ordinary car.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Forget about NetBeans for the time being. That is only a tool to make things faster, and I suspect for many beginners it does more to confuse them than help. Remember that all classes extend another class implicitly, even if you don't say extends. That class is called Object.
I don't remember offhand how to create a class on NetBeans.

If you want ClassB to extend ClassA, you must be sure that whatever ClassB represents is a special kind of whatever ClassA represents. Example:-The case with Taxi can be awkward, because you need to think about how you calculate the charge for passengers, which you would not do for an ordinary car.
why public final class Motorcycle extends Vehicle? what is the difference with the others?final is something that not change as i know like g=10 m/s but in this case what does it means?
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ekte spiriopoulos wrote:why public final class Motorcycle extends Vehicle? what is the difference with the others?final is something that not change as i know like g=10 m/s but in this case what does it means?

  • Motocycle extends Vehicle, because Motocycle is a Vehicle, just like Car is a Vehicle that is why Car extends Vehicle.


  • In this case final means Motorcycle can not be extended by any other class. i.e, it will not allow like below.
  •  
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!