Results 1 to 9 of 9

Thread: Java Relationship Questions

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Answers
    1

    Java Relationship Questions

    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.


  2. #2
    Junior Member
    Join Date
    Mar 2007
    Answers
    1

    Re: Java Relationship Questions

    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


  3. #3
    Junior Member
    Join Date
    Feb 2007
    Answers
    23

    Re: Java Relationship Questions

    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.


  4. #4
    Junior Member
    Join Date
    Feb 2007
    Answers
    23

    Re: Java Relationship Questions

    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.


  5. #5
    Junior Member
    Join Date
    Apr 2007
    Answers
    1

    Re: Java Relationship Questions

    please find the some important questions for Core Java and HR interviews.

    Attached Files Attached Files

  6. #6
    Junior Member
    Join Date
    Aug 2008
    Answers
    1

    Re: Java Relationship Questions

    What is String.intern()?


  7. #7
    Junior Member
    Join Date
    May 2008
    Answers
    8

    Re: Java Relationship Questions

    str.intern() is used to convert normal string class to canonical class

    String s=new String("string");
    String s1=s.intern();


  8. #8
    Junior Member
    Join Date
    Nov 2008
    Answers
    1

    Re: Java Relationship Questions


    we can call garbage collector in java in two ways:
    1)System.gc
    2)RunTime.gc


  9. #9
    Junior Member
    Join Date
    Oct 2009
    Answers
    1

    Re: Java Relationship Questions

    Quote Originally Posted by mohan_java View Post
    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

    hey mohan actually u can use an alternate method to run gc explicitly.
    just use following code.
    "Runtime rt = Runtime.getRuntime();
    rt.gc(); "


  10.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact