Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Java Relationship Questions

This is a discussion on Java Relationship Questions within the Java forums, part of the Software Development category; 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 ...

Go Back   Geeks Talk > Software Development > Java
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Java Java related Issues and Problems

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-01-2007
Junior Member
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Zemi25 is on a distinguished road
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.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-02-2007
Junior Member
 
Join Date: Mar 2007
Location: india
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mohan_java is on a distinguished road
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
Reply With Quote
  #3 (permalink)  
Old 03-02-2007
Junior Member
 
Join Date: Feb 2007
Location: Conway, AR, USA
Posts: 23
Thanks: 0
Thanked 4 Times in 3 Posts
rachilc is on a distinguished road
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.
Reply With Quote
  #4 (permalink)  
Old 03-02-2007
Junior Member
 
Join Date: Feb 2007
Location: Conway, AR, USA
Posts: 23
Thanks: 0
Thanked 4 Times in 3 Posts
rachilc is on a distinguished road
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.
Reply With Quote
  #5 (permalink)  
Old 05-07-2007
Junior Member
 
Join Date: Apr 2007
Location: banagalore
Posts: 2
Thanks: 1
Thanked 1 Time in 1 Post
bhaskar22 is on a distinguished road
Re: Java Relationship Questions

please find the some important questions for Core Java and HR interviews.
Attached Files
File Type: zip PREVIEW_JAVA_J2EE_BOOK.zip (842.6 KB, 104 views)
Reply With Quote
The Following User Says Thank You to bhaskar22 For This Useful Post:
  #6 (permalink)  
Old 10-20-2008
Junior Member
 
Join Date: Aug 2008
Location: India
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
dipak2704 is on a distinguished road
Re: Java Relationship Questions

What is String.intern()?
Reply With Quote
  #7 (permalink)  
Old 11-26-2008
Junior Member
 
Join Date: May 2008
Location: india
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
anveth is on a distinguished road
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();
Reply With Quote
  #8 (permalink)  
Old 12-05-2008
Junior Member
 
Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
vinodkrmenaria is on a distinguished road
Re: Java Relationship Questions


we can call garbage collector in java in two ways:
1)System.gc
2)RunTime.gc
Reply With Quote
  #9 (permalink)  
Old 3 Weeks Ago
Junior Member
 
Join Date: Oct 2009
Location: india
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sagar salunkhe is on a distinguished road
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(); "
Reply With Quote
Reply

  Geeks Talk > Software Development > Java

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Java Interview Questions Ebook Download admin Downloads 222 5 Days Ago 07:51 AM
Relationship in Database RyanJames Database General 1 01-12-2008 01:51 PM
Java Coding Interview Questions promodkumardas Java 0 02-26-2007 09:57 PM
solve the relationship vmshenoy Brainteasers 7 01-16-2007 01:53 AM
Relationship between compilers and executables blenda C and C++ 1 11-12-2006 03:06 PM


All times are GMT -4. The time now is 09:21 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved