Multiple Choice Question

Quiz Guidelines

 

QID: 
382
Question: 

Note: This question may be considered too advanced for this exam.

Given the declaration :
interface Worker { void perform_work(); }

which of the following methods/classes are valid?

Select 2 options 

A.    Worker getWorker(int i){   
return new Worker(){  
 public void perform_work() {         
System.out.println(i); }    }; } 
B.    Worker getWorker(final int i){   
return new Worker() {  
 public void perform_work() {   
 System.out.println(i); }    }; } 
C.    Worker getWorker(int i){  
 int x = i;   
class MyWorker implements Worker  {          
 public void perform_work() {
System.out.println(x); }    }; 
 return new MyWorker(); } 
D.    Worker getWorker(final int i){   
class MyWorker implements Worker {       
  public void perform_work() { 
System.out.println(i); }    };  
 return new MyWorker(); }

Q&A Set: 

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!