File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another Mock Exam Question

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 54.
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 given are A and D
but C also compiles correctly
can anyone give any rerasoning for it
should C be correct or not ?

 
Ajith Kallambella
Sheriff
Posts: 5782
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C looks deceivingly correct, but there should have been a semicolon at the end of the statement int i = 10.
That cup of fresh coffee helped me
Ajith
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic