This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the error

 
nikunj thakur
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Foo8
{
public void doFooStuff()
{
System.out.println("a");
}
public void doFooStuff1()
{
System.out.println("c");
}

}
public class Bar8 extends Foo8
{
public void doFooStuff()
{
System.out.println("b");
}
}
class Test
{
public static void main (String [] args)
{
Foo8 reallyABar = new Bar();
reallyABar.doFooStuff();
//reallyABar.doFooStuff();
//reallyABar.doFooStuff1();


// Legal because Bar is a
// subclass of Foo
// Bar reallyAFoo = new Foo(); // Illegal! Foo is not a
// subclass of Bar
}
}

i am getting exception in thread main error
what is the reason for that
 
Fu Dong Jia
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!

there is not a class Bar in you codes!!!
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi thr

i think Fudong Jia is right


there is no class Bar in your code
but the class name must be Bar8...................
isnt it?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic