Java Programming Questions & Answers: part13



Software Programming : Java Programming QUESTIONS AND ANSWERS :: part13 : 6 to 10

Following Software Programming language Entrance Multiple choice objective type questions and answers will help you in Software Programming 2024 examinations :

6.Analyze the following code: public class Test { public static void main(String[] args) { String s = new String("Welcome to Java"); Object o = s; String d = (String)o; } }

When assigning s to o in Object o = s, a new object is created
When casting o to s in String d = (String)o, a new object is created
When casting o to s in String d = (String)o, the contents of o is changed
s, o, and d reference the same String object
s,o,and d doesnot reference the same String object.

7.The code causes Java to throw int number = Integer.MAX_VALUE + 1;

RuntimeException
Exception
Error
Throwable.
No exceptions.

8.Which of the following method is a static in java.lang.Thread?

run()
sleep(long)
start()
join()
setPriority(int).

9.After Analyzing the following code, which statement is appropriate? class Test { public static void main(String[] args) throws MyException { System.out.println("Welcome to Java"); } } class MyException extends Error { }

You should not declare a class that extends Error, because Error raises a fatal error that terminates the program
You cannot declare an exception in the main method
You declared an exception in the main method, but you did not throw it
The program has a compilation error
You can declare a class that extends error.

10.Every event object has the ________ method. #201. Every event object has the ________ method.

getSource()
getActionCommand()
getTimeStamp()
getWhen()
getKeyChar().

More Java Programming QUESTIONS AND ANSWERS available in next pages

    Health is the greatest gift, contentment is the greatest wealth -Buddha
Opportunity is missed by most people because it is dressed in overalls and looks like work.- Thomas Edison