Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Inheritance.

 
Krish Pinnamaneni
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am telling my understandings regarding extending or instantiating or referencing class A in package source from class C of package destination.
Please tell any body have better idea regarding this.
Thanks,
Krish .

package source; package source;

public class A { class C { }
static int I =10;
A () {}
}

Q1] what are the conditions to instantiate, extend, refer class A by class C of same package source

A] Extending class A by class C of same package:
constructor of super class must not be private. It could be either default or public or protected.

B] Instantiating class A in class C of same package (i.e. source)
Just you can do it using new operator unless class A constructor is private.

C] Referening Class A in class C of same package (i.e. source)
We can do that if Class A is having public or default static members only.
____________________________________________________________________


package source; package destination;

public class A { class C { }
static int I =10;
A () {}
}


Q2] what are the conditions to instantiate, extend, refer class A in source package from class c of destination package


A] Extending class A in by class C of different package say destination;
Then class A must be public and its constructor must be either protected or public.

B] Instantiating class A in class C of different package say destination (i.e. package destination)
Then class A must be public and its constructor must be public.

C] Referencing class A in class C which is in different package (i.e.destin ation)
Then class must be public and only its public static members are accessible.
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hii... i don't get what he is saying ...can anybody explain ?
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Krish

I am afraid that, like Amit, I do not understand your question very well. Would you please explain yourself posting a more specific question?


[ May 14, 2005: Message edited by: Edwin Dalorzo ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic