• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interface again

 
Neha Sawant
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

this code is complaining that Observer interface not found in class B1.
what is my mistake here.
Anyone please
class A implements Runnable{
public void run(){}}
class B1 extends A implements Observer {
public static void main(String args[]){
A a = new A() ;
B1 b = new B1();
Object o=a; Runnable r = o;
Object o=a; Runnable r = (Runnable)o;
//Object o=a; Observer ob = (Observer)o;
Object o=b; Observer o2 = o;
Object o=b; Runnable r = (Runnable)b;
Object o=b; Observer o2 =(Observer)o;
Observer o=new B();
}
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you import the package they're in (java.util)?
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Fei Ng
Ranch Hand
Posts: 1245
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.util.*;
do you have that?
 
Neha Sawant
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx Micheal And FEING
That was my mistake.
Will we be tested on these also.
i.e. do we have to point out whether import statement is missing
_Neha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic