Answer 81)
2) The add method returns false if you attempt to add an element with a duplicate value
I find it a surprise that you do not get an exception.
Answer 82)
1) The program exits via a call to exit(0);
2) The priority of another
thread is increased
3) A call to the stop method of the Thread class
Java threads are somewhat platform dependent and you should be carefull
when making assumptions about Thread priorities. On some platforms you may find
that a Thread with higher priorities gets to "hog" the processor.
Answer 83)
4) The class can only access final variables
Answer 84)
1) To call from the currently running thread to allow another thread of
the same or higher priority to run
Option 3 looks plausible but there is no guarantee that the thread that grabs the cpu time will be of a higher priority. It will depend on the threading algorithm of the Java Virtual Machine and the underlying operating system
Answer 85)
4) Compilation and running with output 0 to 9
Answer 86)
1) None of these options
Because of the lack of a break statement
after the break 10; statement the actual output will be
"ten" followed
by "twenty"
Answer 87)
4) System.gc();
Answer 88)
1) Compilation succeeds and at run time an output of 0 and false
The
default value for a boolean declared at class level is false, and integer is
0;
Answer 89)
1) Compile time error
You will get an error saying something like "Cant make a static reference to a non static variable". Note that the main method is static.
Answer 90)
3) Output of "Not equal"
Despite the actual character strings matching, using the == operator will simply compare memory location. Because the one string was created with the new operator it will be in a different location in memory to the other string.
Answer 91)
4) Compile and run with output of "Pausing" and "Continuing" after a key is hit
An overriden method in a sub class must not throw Exceptions not thrown in the base class. In the case of the method amethod it throws no exceptions and will thus compile without complain. There is no reason that a constructor cannot be protected.
Answer 92)
4) Compile time error because of the line creating the instance of Inner
This looks like a question about inner classes but it is also a reference
to the fact that the main method is static and thus you cannot directly access a
non static method. The line causing the error could be fixed by changing it to
say
Inner i = new Outer().new Inner();
Then the code would compile and run producing the output "Inner"
Answer 93)
1) Error at compile time
If you implement an interface you must create bodies for all methods in that interface. This code will produce an error saying that MyWc must be declared abstract because it does not define all of the methods in WindowListener. Option 4 is nonsense as comments can appear anywhere. Option 3 suggesting that it might compile but not produce output is ment to mislead on the basis that what looks like a constructor is actually an ordinary method as it has a return type.
Answer 94)
4) Compile time error
An error will be caused by attempting to define an integer as static within a method. The lifetime of a field within a method is the duration of the running of the method. A static field exists once only for the class. An approach like this does work with Visual Basic.
Answer 95)
4)int z = 015;
The letters c and s do not exist as literal indicators and a String must be enclosed with double quotes, not single as in this case.
Answer 96)
1)double
4)instanceof
Note the upper case S on switch means it is
not a keyword and the word then is part of Visual Basic but not Java. Also,
instanceof looks like a method but is actually a keyword,
Answer 97)
4) -3.0
Answer 98)
3) one
Command line parameters start from 0 and fromt he first parameter after the name of the compile (normally Java)
Answer 99)
4) The set is designed for unique elements.
Collection is an interface, not a class. The Collection interface includes a
method called iterator. This returns an instance of the Iterator class which has
some similarities with Enumerators.
The name set should give away the purpose
of the Set interface as it is analogous to the Set concept in relational
databases which implies uniquness.
Answer 100)
2) If multiple listeners are added to a component the events will be
processed for all but with no guarantee in the order
4) You may remove as
well add listeners to a component.
It ought to be fairly intuitive that a component ought to be able to have
multiple listeners. After all, a text field might want to respond
to both the mouse and keyboard