1. Given the code String s = new String("abc"); Which of the following call is not valid?
Correct : B. s.replace('a', 'A').
2. The methods wait() and notify() are defined in?
Correct : B. java.lang.Object.
3. Given the following code:~~~class Base { int x = 10; }~~~class Derived extends Base~~~{ int x = 20; }~~~Base b = new Base();~~~Derived d = new Derived (
);~~~Base bd = new Derived(); The statement~~~System.out.println(b.x + " " + d.x + " " + bd.x);~~~will produce the output
Correct : D. 10 20 10.
4. When we implement the Runnable interface, we must define the method
Correct : A. run().
5. 15 & 29 =?
Correct : C. 13.
6. Identify the statements that are not correct:
Correct : B. Int b = -8, b>>1 = -4.
7. Consider the following code: int x, y, z;~~~y = 1;~~~z = 5;~~~x = 0 - (++y) + z++;~~~after execution of this, what will be the values of x, y and z?
Correct : B. x = 3, y = 2, z = 6.
8. What will be the result of the expression: a % b when a & b is of type int and their values~~~are a = 10 and b = 6?
Correct : D. 4.
9. Which of the following statements about abstract methods/classes in JAVA is true?
Correct : A. An abstract class cannot be instantiated.
10. The keywords reserved but used in the initial version of JAVA are:
Correct : A. union.
11. When we invoke repaint() for a JAVA.awt.Component object, the AWT invokes the method _____________.
Correct : A. update().
12. The setBackground() method is part of the following class in JAVA.awt package.
Correct : A. Component.
13. Which of the following methods can be used to draw the outline of a square within a JAVA.awt.Component object?
Correct : A. drawLine().
14. DataInput is ________________.
Correct : A. an interface that defines methods to read primitive data types.
15. Which of the following method can be used to change the size of a JAVA.awt.Component object?
Correct : B. setSize().
16. What method is used to specify a container's layout?
Correct : A. setLayout().
17. 27 | 8 = ?
Correct : B. 27.
18. What will be the result of the expression : a % b~~~when a and b are of type int and their values are a = -17 and b = -6?
Correct : D. 5.
19. Choose the operations that can be performed on String objects:
Correct : A. +=.
20. (1 | 4) + (4 & 2) = ?(in base ten)
Correct : B. 5.
21. Given the declarations~~~boolean b;~~~short x1 = 100, x2 = 200, x3 = 300; Which of the following statement is evaluated to true?
Correct : A. b = x1 * 2 == x2;
22. Which of the following represent legal flow control statements?
Correct : A. break;
23. A class can be converted to a thread by implementing the interface ____________.
Correct : B. Runnable.
24. Which Control Statements allow the program to choose different paths of execution?
Correct : C. selection.
25. ________ are stored in hierarchical manner.
Correct : A. packages.
26. After the following code fragment, what is the value in a?~~~String s; int a;~~~s = "Foolish boy."; a = s.indexOf("fool");
Correct : A. -1.
27. What is an infinite loop?
Correct : B. A loop that runs forever.
28. What is the difference between a TextArea and a TextField?
Correct : A. A TextArea can handle multiple lines of text.
29. What is the purpose of this bit of code?~~~void init()~~~{~~~}
Correct : B. A required method in an applet.
30. A compound statement is ________.
Correct : A. A collection of one or more statements enclosed in braces.
31. Which of the following is NOT an example of a data type?
Correct : B. public.
32. The following is an example of a boolean expression
Correct : C. cause == bYes.
33. A function is: _________________.
Correct : A. An entity that receives inputs and outputs.
34. The data type for numbers such as 3.14159 is _________.
Correct : A. double.
35. Given the following statement: huey.setDouble(8.0*32.2+1.0);~~~What must be the data type of huey?.
Correct : A. DoubleField.
36. Given the following code fragment:~~~int A[];int i = 0;A = new int A[4];~~~while (i < 4)~~~{~~~A[i] = 10;~~~i = i + 1;~~~}~~~What is the value of A[3]?.
Correct : C. 10.
37. What is the value of k after the following code fragment?~~~int k = 0;~~~int n = 12~~~while (k < n)~~~{~~~k = k + 1;~~~}
Correct : C. 12.
38. When an instance of a class, or object, is specified as a parameter to a method, ______ to the said object is passed to the method.
Correct : A. a reference.
39. The modulus operator (%) in JAVA can be used only with variables of ______ type.
Correct : B. int & double.
40. An array of objects, which may have_______ type of different classes.
Correct : A. different.
41. Which of the following statement is false?
Correct : B. The yield() method should be enclosed in try ... catch block.
42. When Java source code is compiled, each individual class is put into its own output file named after the class and using the ______ extension.
Correct : D. .class.
43. Java was conceived by __________.
Correct : C. sun microsystem.
44. An _________ is a special kind of Java program that is designed to be transmitted over the internet.
Correct : B. applet.
45. When you read your e-mail, you are viewing _________ data.
Correct : B. passive.
46. There are ________ types of comments in Java.
Correct : D. four.
47. Java enables the creation of cross-platform programs by compiling into an intermediate representation called Java ____________.
Correct : A. byte code.
48. What class is the top of the AWT event hierarchy?
Correct : B. java.awt.AWTEvent class
49. What does J2SE mean?
Correct : A. Java 2 Platform Standard Edition.
50. Java support RMI. What does this RMI stands for?
Correct : B. Remote Method Invocation.
51. _________ is a feature that allows one interface to be used for a general class of actions.
Correct : C. Polymorphism.
52. What method must be implemented by all threads?
Correct : A. run() method
53. The term _____________ refers to a class's direct ancestor or to any of its ascendant.~~~classes.
Correct : B. super class.
54. A single-line comment begins with a ________ and ends at the end of the line.
Correct : B. // .
55. __________ code segments must be implemented for an event handler.
Correct : C. three.
56. A class is declared by use of the ________ keyword.
Correct : B. class.
57. The new operator dynamically allocates ________ for an object and returns a reference to it.
Correct : C. memory.
58. Method overloading is one of the way that Java supports ____________.
Correct : D. polymorphism.
59. Does a class inherit the constructors of its super class?
Correct : C. Always No
60. Methods declared as static have several restrictions:~~~1) They can only call other static methods.~~~2) They must only access static data.~~~3) They cannot refer
to this or super in any way~~~Which of these are true?
Correct : D. 1, 2 and 3.
61. finalize( ) is only called just prior to _________.
Correct : C. garbage collection.
62. The data or variables, defined within a class are called _______ variables.
Correct : C. instance.
63. In this example class_var = new classname ( ); the class name followed by parentheses~~~specifies the _________ for the class.
Correct : B. constructor.
64. What is meant by timeslicing or time sharing?
Correct : A. Timeslicing is the method of de-allocating CPU time to individual threads in a priority schedule.
65. Which of the following statements correctly describes an interface?
Correct : C. It's a type of abstract class.
66. You would use the ____ operator to create a single instance of a named class.
Correct : A. new.
67. Java's garbage collector runs as a ______ priority thread waiting for _______ priority threads to relinquish the processor. Choose the correct sequence.
Correct : A. high, low.
68. What is the default thread at the time of starting the program?
Correct : A. Main Thread.
69. What is the use of valueOf( ) method?
Correct : D. It converts string to float value.
70. What are the part in executing a Java program and their purposes?
Correct : A. Java Compiler.
71. What is the priority of the Garbage collector thread of jdk?
Correct : A. Low-Priority.
72. What are the constants defined by Byte, Short, Integer and Long? 1. MAX_VALUE, 2.~~~MIN_VALUE 3. TYPE.
Correct : C. 1, 2, 3.
73. What is the unit for 1000 in the below statement? ob.sleep(1000)
Correct : A. Long milliseconds.
74. What will be the result of compiling the following code?~~~public class Test~~~{~~~static int age;~~~public static void main (String args [])~~~{~~~age = age +
1;~~~System.out.println("The age is " + age);~~~}~~~}
Correct : B. Compiles and runs printing out The age is 1.
75. Which of the following helps in garbage collection?
Correct : C. Finalize.
76. __________ is an applet tag.
Correct : C. <applet>.
77. When you divide a number of type double by zero then the result will be __________.
Correct : B. double.NaN.
78. What will happen when the class below is complied?~~~public class Example~~~{~~~//char a = 'u000A';~~~}
Correct : A. Will complete successfully.
79. Codebase attribute in applet tag is used for _________.
Correct : C. base URL for class file.
80. What is the number of bytes used by Java primitive long?
Correct : D. 8.
81. Which of the function is used to convert String to Number in java program?
Correct : C. valueOf() .
82. Interface methods can be declared with which the following modifiers?
Correct : A. public.
83. The class that inherits is called a __________.
Correct : B. subclass.
84. All the wrapper classes (Integer, Boolean, Float, Short, Long, Double and Character).
Correct : D. are private.
85. What is the file extension of compiled java program?
Correct : A. .class.
86. Can you write a Java class that could be used both as an applet as well as an application?
Correct : A. Yes
87. A subclass is also called as ____________.
Correct : C. derived class.
88. ____________ is not a package in java.
Correct : D. ip.
89. What is the output of the following program?
class Example {
public static void main(String args[]) {
int j;
do {
j++;
} while (j < 0);
System.out.println(j);
}
}
Correct : A. The program does not compile as j is not initialized.
90. _____ is used to manage the memory allocation.
Correct : A. New.
91. AWT stands for_________________.
Correct : A. abstract window toolkit.
92. Polymorphism is derived from a ___________ word.
Correct : A. greek
93. Integers are whole values ________ numbers.
Correct : A. signed.
94. Single characters are represented through ______ type.
Correct : B. char.
95. Numbers with fractional are called __________.
Correct : B. float.
96. Single character in java is called _____literals.
Correct : A. char.
97. The ______ refers to the validity of a variable.
Correct : A. scope.
98. Which of the following is not a class?
Correct : C. Int.
99. Package is a collection of __________.
Correct : A. classes.
100. The dot operator is used to access the instance ______.