1.What is an "is a" relationship? How does it apply to the world of objects?
2. What is a "has a" relationship?
3. Explain how parent and child classes are related to base and derived classes.
5. Explain the modifiers public, protected and private.
1.What is an "is a" relationship? How does it apply to the world of objects?
2. What is a "has a" relationship?
3. Explain how parent and child classes are related to base and derived classes.
5. Explain the modifiers public, protected and private.
hi actaully i want to know that " how to call the garbage collector in java"
instead of using system.gc().
bcz if we use that may be or mayn't the jvm will call the GC, but i want to call the GC manually.
plz send me the resplonse
Zemi,
1.what is an "is a" relationship? how does it apply to the world of objects?
when a class inherits from another class, the former is a specific form of the latter. Example, if dog inherits from animal, we can say dog is a animal.
2. What is a "has a" relationship?
whenever one object has a member varibale that is a reference to another object. It is a has a relationship.
For example
class dog { tail dogtail; //here tail is another object }
now we can say a dog has a tail.
3. Explain how parent and child classes are related to base and derived classes.
parent = base class
child = derived class.
I guess it's just terminology
5. Explain the modifiers public, protected and private.
public : all instances of other classes, irrespective of the module, namespace or package can have access to this artifact (class, method, variable)
protected : all instances of other classes in the same package and subclasses in other packages can have acces to this (once child class inherits a protected method or variable, it becomes private with respect to child class). This cannot be applied to top level classes in java.
Private : only, i repeat, only memebrs of the same class can access this. Nobody from outside, even if from same package can access this.
Hope this helps.
For Mohan,
Try not to cross post. Your topic will have more visibilty if it has it's own subject in a separate thread.
Anyway, I am not the moderator, so here goes:
IMHO, you CANNOT guarantee the garbage collecter will run, no matter what method you use.
Two ways to recommend running the garbage collecter are:
System.gc() as you already pointed out.
Runtime rt = Runtime.getRuntime();
rt.gc();
Both serve the same purpose and do not force garbage collecter to run.
please find the some important questions for Core Java and HR interviews.
What is String.intern()?
str.intern() is used to convert normal string class to canonical class
String s=new String("string");
String s1=s.intern();
we can call garbage collector in java in two ways:
1)System.gc
2)RunTime.gc