Java MCQ Quiz Hub

Java Mcq Question Set 8

Choose a topic to test your knowledge and improve your Java skills

Which of the following declares an abstract method in an abstract Java class?





✅ Correct Answer: 3

Which of the following statements regarding abstract classes are true?





✅ Correct Answer: 4

Which of the following is a correct interface?





✅ Correct Answer: 3

Given the following piece of code: public interface Guard{void doYourJob(); } abstract public class Dog implements Guard{ } which of the following statements is correct?





✅ Correct Answer: 2

Runnable is a _____ .





✅ Correct Answer: 1

Which is true?





✅ Correct Answer: 2

The concept of multiple inheritance is implemented in Java by





✅ Correct Answer: 3

The class at the top of exception class hierarchy is .................





✅ Correct Answer: 4

In which of the following package Exception class exist?





✅ Correct Answer: 1

Exception generated in try block is caught in ........... block.





✅ Correct Answer: 2

Which keyword is used to explicitly throw an exception?





✅ Correct Answer: 2

Which exception is thrown when divide by zero statement executes?





✅ Correct Answer: 3

Which keyword is used to specify the exception thrown by method?





✅ Correct Answer: 1

Which of the following blocks execute compulsorily whether exception is caught or not.





✅ Correct Answer: 4

What happen in case of multiple catch blocks?





✅ Correct Answer: 2

Which exception is thrown when an array element is accessed beyond the array size?





✅ Correct Answer: 1

public class Test{public static void main(String args[]){ int a = Integer.parseInt("four"); }}} Which exception could be handled by the catch block for above?





✅ Correct Answer: 1

try{ File f = new File("a.txt"); }catch(Exception e){ }catch(IOException io){ } Is this code create new file name a.txt ?





✅ Correct Answer: 3

In java a thread can be created by ..........





✅ Correct Answer: 3

When a class extends the Thread class ,it should override ............ method of Thread class to start that thread.





✅ Correct Answer: 4

Which of the following constructor of class Thread is valid one?





✅ Correct Answer: 1

Analyze the following code: public abstract class Test implements Runnable{ public void doSomething() { }; }





✅ Correct Answer: 3

Analyze the following code: public class Test implements Runnable{public static void main(String[] args){Test t = new Test(); t.start(); }public void run() { } }





✅ Correct Answer: 2

�Which of the following are methods of the Thread class?





✅ Correct Answer: 4

Output : public class Test implements Runnable{public void run(){System.out.print("go");}public static void main(String arg[]){Thread t = new Thread(new Test()); t.run(); t.run(); t.start();}}





✅ Correct Answer: 3

System class is defined in .................





✅ Correct Answer: 1

try{File f = new File("a.txt"); }catch(Exception e){ }catch(IOException io){ } Is this code create new file name a.txt ?





✅ Correct Answer: 3

Which of these classes defined in java.io and used for file-handling are abstract?





✅ Correct Answer: 3

When comparing java.io.BufferedWriter and java.io.FileWriter, which capability exist as a method in only one of two ?





✅ Correct Answer: 1

What is the range of data type short in Java?





✅ Correct Answer: 1

What is the range of data type byte in Java?





✅ Correct Answer: 1

An expression involving byte, int, and literal numbers is promoted to which of these?





✅ Correct Answer: 2

Which of these literals can be contained in a data type float variable?





✅ Correct Answer: 4

Which data type value is returned by all transcendental math functions?





✅ Correct Answer: 2

What is the numerical range of a char in Java?





✅ Correct Answer: 1

Which of these coding types is used for data type characters in Java?





✅ Correct Answer: 2

Which of these values can a boolean variable contain?





✅ Correct Answer: 1

Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?





✅ Correct Answer: 3

Which one is a valid declaration of a boolean?





✅ Correct Answer: 3

Output : class mainclass { public static void main(String args[]) { boolean var1 = true; boolean var2 = false; if (var1) System.out.println(var1); else System.out.println(var2); } }





✅ Correct Answer: 1

Which of these functions is called to display the output of an applet?





✅ Correct Answer: 1

Which of these methods can be used to output a sting in an applet?





✅ Correct Answer: 3

What does AWT stands for?





✅ Correct Answer: 4

Which of these methods is a part of Abstract Window Toolkit (AWT) ?





✅ Correct Answer: 1

Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?





✅ Correct Answer: 3

Which of these operators can be used to get run time information about an object?





✅ Correct Answer: 2

Which of these packages contain all the collection classes?





✅ Correct Answer: 1