Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refer the program given

 
Abhijit Kangale
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In the following program how many reference varibale & how many objects are there....? please justify if possible.

class animal
{
public void eat()
{
System.out.println("you are in animal");
}
}

class horse extends animal
{
public void eat()
{
System.out.println("you are in horse");
}

}

public class Flo
{
public static void main(String args[])
{
animal d=new animal();
animal f=new horse();
d.eat();
f.eat();

}
}

Thanks & Regards,
ABHIJIT
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In the following program how many reference varibale & how many objects are there....? please justify if possible.


What do you think the answer is ?
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the code button so we can read it, and "Refer the program given" doesn't tell us what the thread is about.
 
Ninad Kulkarni
Ranch Hand
Posts: 802
Hibernate Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abhijit,
There are . . .
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ninad Kulkarni, please have a look at the Beginning Java forum title page, where is says not to give answers. Abhijit Kangale will learn much more by counting the objects than being told.
Please don't be annoyed with me, but I have "pulled rank" and transferred your answer to our "deleted" forum.
 
Ninad Kulkarni
Ranch Hand
Posts: 802
Hibernate Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Campbell Ritchie. It happened by mistake. I apologize for that. I won't do that again.
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apology accepted
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Apology accepted


Aah we can't accept apologies, because Ninad is not allowed to say sorry , so now he'll have to say sorry for saying sorry (I hope this is funny, otherwise someone will kill me for making Poor Jokes)...
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only if you say sorry for that joke . . .

Have you worked out how many objects there were?
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only if you say sorry for that joke . . .

I never say sorry for my jokes, so sorry but no sorry (another joke)

Campbell Ritchie wrote:Have you worked out how many objects there were?

Who me, I won't even try to answer that, otherwise you'll "pull the rank" again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic