MCQs
WindowEvent is generated when a window is activated, closed, deactivated,
deiconfied, iconfied, opened or quit.
Thread t is seeded to currently program, hence when you run the program the thread
becomes active & code 't.isAlive' returns true.
Output:
$ javac multithreaded_programing.java
$ java multithreaded_programing
true
reverse() method reverses all characters. It returns the reversed object on which it was called.
Output:
$ javac output.java
$ java output
olleH
For the 1st iteration -1 is displayed. The 2nd exception is caught in catch block and 0
is displayed.
Output:
$ javac exception_handling.java
$ java exception_handling
-10
AdjustmentEvent is generated when a scroll bar is manipulated.
The output of program is Thread[main,5,main], Since we have not explicitly named the
thread they are named by the group to they belong i:e main method. Hence they are
named ‘main’.
Output:
$ javac multithreaded_programing.java
$ java multithreaded_programing
Thread[main,5,main]
Value of variable sum is printed outside of try block, sum is declared only in try block,
outside try block it is undefined.
Output:
$ javac exception_handling.java
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
sum cannot be resolved to a variable
EventObject class is a super class of all the events and is defined in java.util package.
The output of program is Thread[main,5,main], in this priority assigned to the thread
is 5. Its the default value. Since we have not named the thread they are named by
the group to they belong i:e main method.
Output:
$ javac multithreaded_programing.java
$ java multithreaded_programing
Thread[main,5,main]
length() method is used to obtain length of StringBuffer object, length of "Hello" is 5.
Output:
$ javac output.java
$ java output
5