Win a copy of Head First Agile this week in the Agile forum!
    Bookmark Topic Watch Topic
  • New Topic

Inheritance  RSS feed

 
Rafi Fareen
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Report post to moderator
hey guys,

give me your advises (on the way to scjp exam)

as you can see the code.

1. In case both the files are in the same package than there is no problem in inheritance unless the methods of Car class are private.
2. but when the classes are in the separated directories as below than i can only use two access specifiers for methods of class Car so that they get inherited in class test5, that two are, public and protected.
if i don't specify a access-level than it will be by default package, which means no matter inherited from where as long as its outside that package it cannot be accessed.

i used to mark those two methods(fast,slow) as package(i didn't specify the access specifiers) than i couldn't access them in test5.

i'm little bit confused, though i understand how it works, but i need some advises and recommendations from those who have experience in such tricky topics.






thanks guys,
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
You understanding is perfect !

What do you want to know more ?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12146
255
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please continue any discussions in this duplicate topic
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!