aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Listeners and Adupters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Listeners and Adupters" Watch "Listeners and Adupters" New topic
Author

Listeners and Adupters

prasanna perera
Greenhorn

Joined: Oct 05, 2000
Posts: 16
Question 43.
Which of the following class declaration(s) is(are) true?
A.import java.awt.Button;
import java.lang.Runnable;
public class MyClass extends Button implements Runnable{
public void run(){
//Some valid Code
}
}
B.import java.awt.event.*;
import java.applet.Applet;

public class MyApplet extends Applet,WindowAdapter{
public void windowClosed(WindowEvent we){
//Some Valid Code
}
}
C.import java.lang.Runnable;

public class MyClass implements Runnable{
public void run(){
int i = 10
System.out.println("i = "+i);
}
}
D.import java.awt.event.*;
public class MyClass extends WindowAdapter
implements WindowListener{
public void windowClosed(WindowEvent we){
//Some Valid Code
}
}
answers give: a,d
However, I think b,c are correct and d is wrong as when the class implements WindowListener the class has to declare all the methods in this listener interface ?
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3313
    
    7
B is wrong :
public class MyApplet extends Applet,WindowAdapter{
You cannot extend from two classes ( Applet, WindowAdapter)

C looks OK to me.
D. You are correct to say that a class has to define all the methods of the interface wich it says it implements but here, the class is also extending from WindowAdapter. So, it gets (inherits) all the required methods from the Super class. So it need not define those methods again.
Also, it would be helpful to compile the code snippets (in a dummy program) and analyse the results.
HTH,
Paul.

------------------
Get Certified, Guaranteed!
Now Revised for the new Pattern) www.enthuware.com/jqplus
[This message has been edited by Paul Anil (edited October 09, 2000).]


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
Naresh Gupta
Greenhorn

Joined: Oct 09, 2000
Posts: 2
Note that in C answer, semicolon is missing and so it is not correct.

Naresh Gupta
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Listeners and Adupters