• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in abstract class  RSS feed

 
vsk shankar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class abc{
public void roam(){
System.out.println("hi i m vidya ");
}
}

class dog extends abc{
public void roam(){
System.out.println("hi i m vidya ");
}
}

abstract class xyz extends abc {
public void roam(){
System.out.println("hi ravi is tiger");
}
}



class kamal {
public static void main(String[] args ){
xyz a;
a=new dog();
a.roam();
}
}

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's the problem?
 
vsk shankar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its give a error but haed fist java say its no problem ,,but i m unable to compile
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vsk shankar wrote:its give a error but haed fist java say its no problem ,,but i m unable to compile


Perhaps you read the quote from Head First Java out of context. A dog instance is NOT an instance of xyz in this example, and hence, the assignment is not allowed.

Henry
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!