![]() |
|
| #101 | Which of the following can prevent a thread from executing? | |
| (1) | A call to its pause method | |
| (2) | A call to Thread.yield() | |
| (3) | Another thread is given higher priority | |
| (4) | A call to its halt() method | |
| Answer : ------------------------- | ||
| #102 | Which of the following represent correct syntax for assertions? | |
| (1) | assertion(b==false); | |
| (2) | assert (b==false); | |
| (3) | assert() b==false; | |
| (4) | if(b!=true) assert; | |
| Answer : ------------------------- | ||
| #103 | What will happen if you attempt to compile and run the following code?
| |
| (1) | Compilation but no output as the run method of slave is not correct | |
| (2) | Compilation and output of 100 several times followed by 200 several times | |
| (3) | Compilation and repeated output of 100 | |
| (4) | Compile time error, while cannot be given an unconditional boolean value | |
| Answer : ------------------------- | ||
| #104 | What will happend when you attempt to compile and run the following code?
| |
| (1) | Compile time error | |
| (2) | Compilation and output of "Techno park" | |
| (3) | Compilation and output of "Techno park 0 1 2 3" | |
| (4) | Compilation and probably output of "Techno" but possible output of "Techno 0 1 2 3" | |
| Answer : ------------------------- | ||
| #105 | Which of the following require explicit try/catch exception handling by the programmer? | |
| (1) | Traversing each member of an array | |
| (2) | Attempting to open a file | |
| (3) | Attempting to open a network socket | |
| (4) | Accessing a method in other clas | |
| Answer : ------------------------- | ||
| #106 | What will be the result when you attempt to compile this program?
| |
| (1) | Compile time error referring to a cast problem | |
| (2) | A random number between 1 and 10 | |
| (3) | A random number between 0 and 1 | |
| (4) | A compile time error about random being an unrecognised method | |
| Answer : ------------------------- | ||
| #107 | Which of the following statements are true? | |
| (1) | The vaue of the Integer class can be changed using the = operator | |
| (2) | The value of the Integer class can be changed using the setValue method | |
| (3) | The value of the Integer class can be changed using the setInt method | |
| (4) | Once assigned the value of an instance of Integer cannot be changed | |
| Answer : ------------------------- | ||
| #108 | What will happen when you attempt to compile and run the following code?
| |
| (1) | Compile time error, a19 cannot be used as a method name | |
| (2) | Compilation and output of BillKathyCarl | |
| (3) | Compilation and output of BillCarlKathy | |
| (4) | Compilation and output of abc | |
| Answer : ------------------------- | ||
| #109 | What will happen when you attempt to compile and run the following code?
| |
| (1) | Compilation and output of Val Biddy 3 | |
| (2) | Compilation and output of Val Biddy 3.0 | |
| (3) | Compilation and output of Biddy Val 3.0 | |
| (4) | Compile time error, wrong parameter type passed to method shep | |
| Answer : ------------------------- | ||
| #110 | which of the following statements are true of the ArrayList class? | |
| (1) | It can store primitive or references as elements | |
| (2) | It implements the List interface | |
| (3) | It has a get(int index) method which returns the element at the specified position in the list | |
| (4) | The elements are ordered but not sorted | |
| Answer : ------------------------- | ||
| #111 | What will happen when you attempt to compile and run the following code?
| |
| (1) | Compile time error | |
| (2) | Compilation and output fo 3.5 | |
| (3) | Compilation and output of 3 | |
| (4) | Compilation but no output at runtime | |
| Answer : ------------------------- | ||
| #112 | Which of the following statements are true? | |
| (1) | A variable declared as public within a method will always be visible from code anywhere else in the class | |
| (2) | A variable declared as public at class level will always be visible from code anywhere else in the class | |
| (3) | A method with no visibility modifier can be less visible than one declared with the protected modifier | |
| (4) | Only one copy will ever exist of a method variable declared as static | |
| Answer : ------------------------- | ||
| #113 | Which of the following are valid uses of the assert statement? | |
| (1) | assert(); | |
| (2) | assert { int > 0; } | |
| (3) | assert(iMonth < 12); | |
| (4) | assert (iAge = 0); | |
| Answer : ------------------------- | ||
| #114 | At what point will the object created on line 8 be eligible for garbage collection?
| |
| (1) | Line 11 | |
| (2) | Line 9 | |
| (3) | Line 12 | |
| (4) | Line 13 | |
| Answer : ------------------------- | ||
| #115 | What will happen when you attempt to compile and run the following code?
| |
| (1) | Compile time error, System.out has no print method | |
| (2) | No output at runtime | |
| (3) | Output of 0 | |
| (4) | Compile error, break cannot occur after its target label | |
| Answer : ------------------------- | ||
| #116 | What will happen when you attempt to compile the following code?
| |
| (1) | Compile time error, class Wmid may not be marked as protected | |
| (2) | Compile time error, a constructor may not be marked as private | |
| (3) | Compilation and output of Wmid | |
| (4) | Compilation but no output | |
| Answer : ------------------------- | ||
| #117 | What will happen when you attempt to compile and run the following code?
| |
| (1) | Compile time error | |
| (2) | Compilation but runtime exception | |
| (3) | Compilation but no output at runtime | |
| (4) | Compilation and output of "interrupted" at runtime | |
| Answer : ------------------------- | ||
| #118 | Which of the following statements are true? | |
| (1) | A LinkedHashMap preserves the order in which objects are added | |
| (2) | A TreeMap ensures that its elements will be in sorted order | |
| (3) | Elements in a LinkedList are sorted but not ordered | |
| (4) | Collections that implement the List interface allow duplicate elements | |
| Answer : ------------------------- | ||
| #119 | Select one correct statement about the following code.
| |
| (1) | Prints randomly 6 or 8 at each execution | |
| (2) | Prints randomly 7 or 8 at each execution | |
| (3) | Always prints 6 at each execution | |
| (4) | Prints randomly 6 or 11 at each execution | |
| (5) | Compilation error | |
| Answer : ------------------------- | ||
| #120 | An ArithmeticException is a checked exception. True Or False? | |
| (1) | True | |
| (2) | False | |
| Answer : ------------------------- | ||
| #121 | Assume the bit pattern of byte x is: 10110001. What will the sign of x be after x >> 2? Fill with positive Or negative. Caution: No spaces or extra characters. | |
| Answer : ------------------------- | ||
| #122 | In a switch statement, the argment to the case label (case argument:) can be any variable which can fit within an int. True/False? | |
| (1) | True | |
| (2) | False | |
| Answer : ------------------------- | ||
| #123 | Overloaded methods must not throw new checked exceptions not thrown by the original method. True/False? | |
| (1) | True | |
| (2) | False | |
| Answer : ------------------------- | ||
| #124 | Which of the following statements are true? | |
| (1) | Assigning null to a reference causes the object to be garbage collected | |
| (2) | Assigning null to a reference causes the object to become eligable for garbage collection | |
| (3) | An object is eligable for garbage collection once it is unreachable via any reference | |
| (4) | Any object created within a method will be eligable for garbage collection once the method ceases execution | |
| Answer : ------------------------- | ||
| #125 | Which of the following statements are true about the LinkedHashSet class? | |
| (1) | It may not contain duplicate elements | |
| (2) | The elements are ordered but not sorted | |
| (3) | The elements are sorted | |
| (4) | It does not permit null elements | |
| Answer : ------------------------- | ||
| #126 | Given the following code, which option if inserted after the line with the comment //Here will result in code that will compile and output SupEx?
| |
| (1) | SupEx s = new Super(); | |
| (2) | Super s = new SupEx(); | |
| (3) | SupEx s = new SupEx(); | |
| (4) | Super s = new Super(); | |
| Answer : ------------------------- | ||
| #127 | Which of the following will result in an output of 10? | |
| (1) | System.out.println(Math.round(10.1)); | |
| (2) | System.out.println(Math.floor(10.1)); | |
| (3) | System.out.println(Math.abs(10.1)); | |
| (4) | System.out.println(Math.min(10.1)); | |
| Answer : ------------------------- | ||
| #128 | Given this code, which of the following statements are true?
| |
| (1) | The hashCode method is correctly implemented | |
| (2) | The hashCode method is not correct because it is inconsistant with the equals method | |
| (3) | The code will not compile because there is a circular reference to the hashCode method | |
| (4) | The code will not compile because the return value of this.hashCode is not an int value | |
| (5) | The code will not compile because it does not implement the comparable interface | |
| Answer : ------------------------- | ||
| #129 | Which of the following statements are true? | |
| (1) | A higher priority Thread will prevent a lower priorty Thread from getting any access to the CPU | |
| (2) | The yield method only allows any higher priority priority thread to execute | |
| (3) | The Thread class has a static method called yield | |
| (4) | Calling yield with an integer parameter causes it to yield for a specific time | |
| Answer : ------------------------- | ||
| #130 | How do you set the priority of the thread "newThread" to the minimum of two values: maximum priority and current priority incremented to the next level. [Use the Thread priority constants and do not insert any extra characters or leave any blank spaces] | |
| Answer : ------------------------- | ||
| #131 | Variables declared within methods cannot be marked as static. True/False? | |
| (1) | True | |
| (2) | False | |
| Answer : ------------------------- | ||
| #132 | What is the initial capacity of an empty StringBuffer object? ie., new StringBuffer() [No extra characters Or spaces] | |
| Answer : ------------------------- | ||
| #133 | What is the capacity of strBuf object after executing the following statement? StringBuffer strBuf = new StringBuffer("Technopark"); | |
| (1) | 0 | |
| (2) | 6 | |
| (3) | 25 | |
| (4) | 255 | |
| (5) | -1 | |
| (6) | None of the above | |
| Answer : ------------------------- | ||
| #134 | How can you remove the superfluous capacity of a StringBuffer object say strBuf (if there is any)? (Hint: Use SetLength() and length() methods. Please do not include any extra characters Or spaces) | |
| Answer : ------------------------- | ||
| #135 | What will be the result of attempting to compile and run the following code?
| |
| (1) | The code will fail to compile, since the constructor of the String class is not properly called | |
| (2) | The code will fail to compile, since (s == sb) is an illegal expression | |
| (3) | The code will fail to compile, since the expression (s.equals(sb)) is illegal | |
| (4) | The code will print c when run | |
| (5) | The program will throw a ClassCastException when run | |
| Answer : ------------------------- | ||
| #136 | At which point will the word "Harpic" be printed out when this code is executied?
| |
| (1) | After executing the line after the comment //one | |
| (2) | After executing the line after the comment //two | |
| (3) | After executing the line after the comment //three | |
| (4) | It is impossible to say, the String "Harpic" may not be output at all | |
| Answer : ------------------------- | ||
| #137 | What will happen when you attempt to compile and run the following code?
| |
| (1) | Compilation, but output at runtime will cannot be exactly determined | |
| (2) | Compilation and output of "running" | |
| (3) | Compilation but no output at runtime | |
| (4) | Compile time error | |
| Answer : ------------------------- | ||
| #138 | What will happen if you compile the following code with assertions enabled?
| |
| (1) | Compile time error, AssertionError has no int constructor | |
| (2) | Compile time error AssertionError does not exist | |
| (3) | Assertion Error at runtime if given a command line parameter of 0 | |
| (4) | If given a command line parameter of 1, 1 will be output at runtime | |
| Answer : ------------------------- | ||
| #139 | What will happen if you attempt to compile and run the following code?
| |
| (1) | Compilation and output of 3 | |
| (2) | Compile time error, duplicate elements cannot be added to HashSet | |
| (3) | Runtime error due to an attempt to add duplicate elements to a HashSet | |
| (4) | Compilation and output of 2 | |
| Answer : ------------------------- | ||
| #140 | AssertionError exceptions are checked exceptions. True Or False? | |
| (1) | True | |
| (2) | False | |
| Answer : ------------------------- | ||
| #141 | What will the output be when the following method is executed?
| |
| (1) | 11 10 9 final 8 | |
| (2) | 10 9 8 final 8 | |
| (3) | 11 10 9 8 final 8 | |
| (4) | 11 final 10 | |
| Answer : ------------------------- | ||
| #142 | Consider the following main method in the TechnoSample class:
What will be printed when this is executed with the following command line? java TechnoSample alpha beta gamma delta | |
| (1) | :Arg betagamma: | |
| (2) | :Argbetagamma: | |
| (3) | : Arg betagamma: | |
| (4) | : Arg alphabeta: | |
| (5) | :Arg alphabeta: | |
| Answer : ------------------------- | ||
| #143 | What will happen when you attempt to compile and run the following code? class WornPadException extends RuntimeException{ } public class Wheel{ public static void main(String argv[]){ Wheel w = new Wheel(); System.out.print(w.roll()); } public int roll(){ int iDistance =0; try{ for(int i =0; i < 2 ;i ++){ System.out.print("roll"); iDistance = iDistance * i; } return iDistance; }finally{ brake(); System.out.print("finished"); return iDistance+1; } } public void brake() throws WornPadException{ System.out.print("brake"); } } | |
| (1) | Compile time error, calls to brake must be within a try/catch block | |
| (2) | Compile time error the try block has no catch clause | |
| (3) | Runtime error, the call to brake is not within a try/catch block | |
| (4) | Runtime error the call to brake is within a finally clause | |
| (5) | Compilation and output of rollrollbrakefinished0 | |
| (6) | Compilation and output of rollrollbrakefinished1 | |
| Answer : ------------------------- | ||
| #144 | Select all of the following statements that are true. | |
| (1) | The Float class has constructors that take type String, type double and type float | |
| (2) | The * operator can be used to multiply the values of instances of the Integer class | |
| (3) | The setValue method can be used to alter the value of an instance of Integer, Float or Double | |
| (4) | The Character class can store either a char value or a String value | |
| (5) | The Integer.parseInt method will convert an appropriate String to its int value | |
| Answer : ------------------------- | ||
| #145 | When programming a local inner class inside a method code block, which of the following statements is true? Check all which apply. | |
| (1) | The inner class will only have access to static variables in the enclosing class | |
| (2) | The inner class can use any local variables declared in the method | |
| (3) | The only local variables an inner class can use are those that are declared final | |
| (4) | The only local variables an inner class can use are those that are declared static | |
| (5) | The inner class will only have access to instance and local variables if they are declared final | |
| Answer : ------------------------- | ||
| #146 | Which of the following are public variables or methods that belong to an instance of Thread? Do not select static variables, static methods, or deprecated methods. | |
| (1) | wait() method | |
| (2) | sleep() method | |
| (3) | start() method | |
| (4) | MAX_PRIORITY - an int variable | |
| (5) | daemon - a boolean variable | |
| Answer : ------------------------- | ||
| #147 | Which of the following is not a Java keyword? (Java SDK v1.4) | |
| (1) | transient | |
| (2) | generic | |
| (3) | assert | |
| (4) | strictfp | |
| (5) | friend | |
| (6) | sizeof | |
| Answer : ------------------------- | ||
| #148 | Consider the variables declared in the following code:
Select statements that could replace the comment without causing a compiler error. | |
| (1) | theInts = caps; | |
| (2) | theObj = theInts; | |
| (3) | someObj = theInts; | |
| (4) | theObj = caps; | |
| Answer : ------------------------- | ||
| #149 | What will happen when we try to compile and run this code?
| |
| (1) | The compiler will object to line 4 because the object types of ss and cc don't match | |
| (2) | The program will compile and run, producing "EQ" | |
| (3) | The program will compile and run, producing "equalsEQ" | |
| (4) | The program will compile and run, producing "equals" | |
| (5) | The compiler will object to creating an Integer from a char in line 2 | |
| Answer : ------------------------- | ||
| #150 | Your program has two object references, x and y. In some method the following logical tests are done:
Which of the following statements about the relationship between these tests are true. | |
| (1) | If equalsFlag is true, then hashFlag must be true | |
| (2) | If hashFlag is true, then eqFlag must be true | |
| (3) | If equalsFlag is false, then eqFlag must be false | |
| (4) | if hashFlag is false, then eqFlag must be false | |
| Answer : ------------------------- | ||