0
Q:

public class Threads2 implements Runnable {

public void run() {

System.out.println("run.");

throw new RuntimeException("Problem");

Which among the following is true?

}

public static void main(String[] args) {

Thread t = new Thread(new Threads2());

t.start();

System.out.println("End of method.");

}

}

A) java.lang.RuntimeException: Problem B) run. java.lang.RuntimeException: Problem
C) End of method. java.lang.RuntimeException: Problem D) End of method. run. java.lang.RuntimeException: Problem

Answer:   D) End of method. run. java.lang.RuntimeException: Problem



Explanation:

Only D can be true

Subject: Java
Q:

X implements Y, Z

Arguments:

1. X should be class
2. Y, Z should be interfaces

A) Only 1 is true B) Only 2 is true
C) Both 1 and 2 are true D) None
 
Answer & Explanation Answer: C) Both 1 and 2 are true

Explanation:

Both the statements are true 

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

0 14397
Q:

Which of the following are valied?

A) A class can extend any number of classes simulteneously B) A class can implement only one interface at a time
C) A class can extend other class or can implement interface but not both simulteneously D) None of the above
 
Answer & Explanation Answer: D) None of the above

Explanation:

A is wrong because a class can extend nly one class .B is wrong because a class can implement any number of interfaces.C is wronb because both can can be done simulteneously.So, D is correct

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

1 3571
Q:

public abstract class Shape {

private int x;

private int y;

public abstract void draw();

public void setAnchor(int x, int y) {

this.x = x;

this.y = y;

}

}

Which two classes use the Shape class correctly?

A) public class Circle implements Shape { private int radius; B) public abstract class Circle extends Shape { private int radius; }
C) public class Circle extends Shape { private int radius; public void draw(); D) None
 
Answer & Explanation Answer: B) public abstract class Circle extends Shape { private int radius; }

Explanation:

Only B is true

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 14084
Q:

public abstract class Shape {

private int x;

private int y;

public abstract void draw();

public void setAnchor(int x, int y) {

this.x = x;

this.y = y;

}

}

Which two classes use the Shape class correctly?

A) public class Circle implements Shape { private int radius; B) public abstract class Circle extends Shape { private int radius; }
C) public class Circle extends Shape { private int radius; public void draw(); D) None
 
Answer & Explanation Answer: B) public abstract class Circle extends Shape { private int radius; }

Explanation:

Only B is true

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 23386
Q:

void waitForSignal() {

Object obj = new Object();

synchronized (Thread.currentThread()) {

obj.wait();

obj.notify();

}

}

Which statement is true?

A) This code can throw an InterruptedException. B) This code can throw an IllegalMonitorStateException.
C) This code can throw a TimeoutException after ten minutes D) All the above
 
Answer & Explanation Answer: B) This code can throw an IllegalMonitorStateException.

Explanation:

It will throw  IllegalMonitorStateException.

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

6 23289
Q:

Which kind of inheritance is not supported directly through classes in java?

A) Multilevel B) Multiple
C) Single D) Hirarcheal
 
Answer & Explanation Answer: B) Multiple

Explanation:

Multiple inheritance is not supported directly but it is achieved through the concept of Interface

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: Software Architect

0 2870
Q:

Which among the following is a scope resolution operator?

A) : B) ::
C) :? D) None
 
Answer & Explanation Answer: B) ::

Explanation:

:: is the scope resolution operator

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: Software Architect

0 4992
Q:

What is the output of this program ?

class main_arguments {
            public static void main(String [ ] args)
            {
                String [][] argument = new String[2][2];
                int x;
                argument[0] = args;
                x = argument[0].length;
                for (int y = 0; y < x; y++)
                    System.out.print(" " + argument[0][y]);           
            }
        }

A) 1 1 B) 1 0
C) 1 0 3 D) 1 2 3
 
Answer & Explanation Answer: D) 1 2 3

Explanation:

In argument[0] = args;, the reference variable arg[0], which was referring to an array with two elements, is reassigned to an array (args) with three elements.
Output:
$ javac main_arguments.java
$ java main_arguments
1 2 3

Report Error

View Answer Report Error Discuss

Filed Under: Java
Exam Prep: GATE

0 17705