Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Regarding Inheritance.

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 817
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hii... i don't get what he is saying ...can anybody explain ?
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic