Multiple Choice Question

Quiz Guidelines



Note: This question may be considered too advanced for this exam. What will the code shown below print when compiled and run with the following command line?

java WarZone self interface XMen {
void shoot(String a);
}public class WarZone {
public static void main(String[] args){
XMen x = null;
if(args.length() > 0){
x = new XMen(){
public void shoot(String s){
for(int i=0; i<s.length; i++){
System.out.println("shot : "+s.charAt(i));
}if(x != null){

Select 1 option

A. It will not compile because interface XMen cannot be instantiated.
B. It will print shot : 4 times, one at each line.
C. It will print "shot : s", "shot : e", "shot : l", "shot : f" one by one on 4 lines.
D. It will compile but will throw an exception at runtime.
E. None of these options is correct.

Q&A Set: 

Search the Web

Custom Search

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