MCQs > IT & Programming > Java MCQs > Basic Java MCQs

Basic Java MCQ

1. A(n) ________ is used as an index to pinpoint a specific element within an array.

Answer

Correct Answer: Subscript

Note: This Question is unanswered, help us to find answer for this one

2. A(n) ____ causes a value to be sent from a called method back to the calling method.

Answer

Correct Answer: Return statement.

Note: This Question is unanswered, help us to find answer for this one

3. A ____ consists of written steps in diagram form, as a series of shapes connected by arrows.

Answer

Correct Answer: Flowchart

Note: This Question is unanswered, help us to find answer for this one

4. If you want all objects to share a single nonchanging value, then the field is static and ______.

Answer

Correct Answer: Final

Note: This Question is unanswered, help us to find answer for this one

5. The value of the responsetext property is almost always a(n) ____ string.

Answer

Correct Answer: JSON

Note: This Question is unanswered, help us to find answer for this one

6. You use a unary minus sign preceding a value to make the value ____.

Answer

Correct Answer: Negative

Note: This Question is unanswered, help us to find answer for this one

7. Methods used with object instantiations are called ____ methods.

Answer

Correct Answer: Instance

Note: This Question is unanswered, help us to find answer for this one

8. A(n) ____ variable is known only within the boundaries of the method.

Answer

Correct Answer: Local

Note: This Question is unanswered, help us to find answer for this one

9. A(n) ____ loop is one that performs no actions other than looping.

Answer

Correct Answer: Do-nothing.

Note: This Question is unanswered, help us to find answer for this one

10. A declaration for an enumerated type begins with the ________ key word.

Answer

Correct Answer: Enum.

Note: This Question is unanswered, help us to find answer for this one

11. A decision symbol in an activity diagram takes the shape of a ________.

Answer

Correct Answer: Diamond.

Note: This Question is unanswered, help us to find answer for this one

12. If you declare an array double[] list = {3.4, 2.0, 3.5, 5.5}, list[1] is ________.

Answer

Correct Answer: 3.

Note: This Question is unanswered, help us to find answer for this one

13. ""aba"".comparetoignorecase(""abc"") returns ________.

Answer

Correct Answer: -2

Note: This Question is unanswered, help us to find answer for this one

14. Assigning ____ to a field means that no other classes can access the field?s values.

Answer

Correct Answer: Private access

Note: This Question is unanswered, help us to find answer for this one

15. For ease in locating class methods, many programmers store them in ____ order.

Answer

Correct Answer: Alphabetical

Note: This Question is unanswered, help us to find answer for this one

16. By convention, a class diagram contains the ____ following each attribute or method.

Answer

Correct Answer: Data type

Note: This Question is unanswered, help us to find answer for this one

17. A(n) ____ method is a method that creates and initializes class objects.

Answer

Correct Answer: Constructor

Note: This Question is unanswered, help us to find answer for this one

18. Class ________ represents an image that can be displayed on a jlabel.

Answer

Correct Answer: ImageIcon.

Note: This Question is unanswered, help us to find answer for this one

19. A logical structure called a(n) ____ structure is when one step follows another unconditionally.

Answer

Correct Answer: Sequence

Note: This Question is unanswered, help us to find answer for this one

20. When you are working with a ________, you are using a storage location that holds a piece of data.

Answer

Correct Answer: Primitive variable

Note: This Question is unanswered, help us to find answer for this one

21. When an expression containing a ____ is part of an if statement, the assignment is illegal.

Answer

Correct Answer: Single equal sign

Note: This Question is unanswered, help us to find answer for this one

22. When a parameter is a(n) ______ data type, any changes made in a method are preserved.

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

23. To prevent a class from being instantiated, ________.

Answer

Correct Answer: Use the private modifier on the constructor.

Note: This Question is unanswered, help us to find answer for this one

24. To guarantee that the member variables of a class are initialized, you use ____.

Answer

Correct Answer: Constructors

Note: This Question is unanswered, help us to find answer for this one

25. The term ________ typically refers to the device that displays console output.

Answer

Correct Answer: Standard output device

Note: This Question is unanswered, help us to find answer for this one

26. The name of the ____ is always the same as the name of the class whose objects it constructs.

Answer

Correct Answer: Constructor

Note: This Question is unanswered, help us to find answer for this one

27. The iterator() method is defined in the ________ interface.

Answer

Correct Answer: Iterable

Note: This Question is unanswered, help us to find answer for this one

28. The conditional operator ?: takes ____ arguments.

Answer

Correct Answer: Three

Note: This Question is unanswered, help us to find answer for this one

29. The capability to inherit from more than one class is called ____.

Answer

Correct Answer: Multiple inheritance

Note: This Question is unanswered, help us to find answer for this one

30. Java and c++ are _____ languages.

Answer

Correct Answer: High-level

Note: This Question is unanswered, help us to find answer for this one

31. If a compiler detects a violation of language rules, it refuses to translate the class to ____.

Answer

Correct Answer: Machine code

Note: This Question is unanswered, help us to find answer for this one

32. Fill in the code in comparable________ c = new date();

Answer

Correct Answer:

Note: This Question is unanswered, help us to find answer for this one

33. A sentinel value ________ and signals that there are no more values to be entered.

Answer

Correct Answer: Is a special value that cannot be mistaken as a member of the list

Note: This Question is unanswered, help us to find answer for this one

34. A method that is associated with an individual object is called ________.

Answer

Correct Answer: An instance method

Note: This Question is unanswered, help us to find answer for this one

35. You use a ____ following the closing brace of an array initialization list.

Answer

Correct Answer: ;

Note: This Question is unanswered, help us to find answer for this one

36. Whenever a method requires multiple arguments, the arguments are always separated with ____.

Answer

Correct Answer: Commas

Note: This Question is unanswered, help us to find answer for this one

37. When you use the && operator, you must include a complete _____ on each side.

Answer

Correct Answer: Boolean expression

Note: This Question is unanswered, help us to find answer for this one

38. When working with logical operators, you can always use ____ to change precedence.

Answer

Correct Answer: Parentheses

Note: This Question is unanswered, help us to find answer for this one

39. The characters ____ move the cursor to the next line when used within a println() statement.

Answer

Correct Answer: \n

Note: This Question is unanswered, help us to find answer for this one

40. Method names that begin with ____ and set are very typical.

Answer

Correct Answer: Get

Note: This Question is unanswered, help us to find answer for this one

41. Method calls cannot be distinguished by ________.

Answer

Correct Answer: Return type

Note: This Question is unanswered, help us to find answer for this one

42. An if statement that appears inside another if statement is referred to as __________.

Answer

Correct Answer: Nested if statement

Note: This Question is unanswered, help us to find answer for this one

43. A(n) ____ comparison is based on the integer Unicode values of the characters.

Answer

Correct Answer: Lexicographical

Note: This Question is unanswered, help us to find answer for this one

44. From which class do all other classes implicitly extend?

Answer

Correct Answer: Object

Note: This Question is unanswered, help us to find answer for this one

45. What keyword is added to a method declaration to ensure that two threads do not simultaneously execute it on the same object instance?

Answer

Correct Answer: Synchronized

Note: This Question is unanswered, help us to find answer for this one

46. An _ is a serious issue thrown by the JVM that the JVM is unlikely to recover from. An _ is an unexpected event that an application may be able to deal with in order to continue execution.

Answer

Correct Answer: Error, exception

Note: This Question is unanswered, help us to find answer for this one

47. Which code checks whether the characters in two Strings,named time and money, are the same?

Answer

Correct Answer: If(time.equals(money)){}

Note: This Question is unanswered, help us to find answer for this one

48. What language feature allows types to be parameters on classes, interfaces, and methods in order to reuse the same code for different data types?

Answer

Correct Answer: Generics

Note: This Question is unanswered, help us to find answer for this one

49. Which statement about constructors is not ture?

Answer

Correct Answer: Every class must explicitly define a constructor without parameters.

Note: This Question is unanswered, help us to find answer for this one

50. Which choice is the best data type for working with money in Java?

Answer

Correct Answer: BigDecimal

Note: This Question is unanswered, help us to find answer for this one

51. Which language feature ensures that objects implementing the AutoCloseable interface are closed when it completes?

Answer

Correct Answer: Try-with-resources

Note: This Question is unanswered, help us to find answer for this one

52. Which class does not implement the java.util.Collection interface?

Answer

Correct Answer: Java.util.HashMap

Note: This Question is unanswered, help us to find answer for this one

53. Which class acts as root class for Java Exception hierarchy?

Answer

Correct Answer: Throwable

Note: This Question is unanswered, help us to find answer for this one

54. What will this code print, assuming it is inside the main method of a class?System.out.println("hello my friends".split(" ")[0]);

Answer

Correct Answer: Hello

Note: This Question is unanswered, help us to find answer for this one

55. Which code snippet is valid?

Answer

Correct Answer: ArrayList words = new ArrayList<>(Arrays.asList("Hello", "World"));

Note: This Question is unanswered, help us to find answer for this one

56. In Java, what is the scope of a method's argument or parameter?

Answer

Correct Answer: Inside the method

Note: This Question is unanswered, help us to find answer for this one

57. What phrase indicates that a function receives a copy of each argument passed to it rather than a reference to the objects themselves?

Answer

Correct Answer: Pass by value

Note: This Question is unanswered, help us to find answer for this one

58. When should you use a static method?

Answer

Correct Answer: When you want your method to be available independently of class instances

Note: This Question is unanswered, help us to find answer for this one

59. Which operator is used to concatenate Strings in Java

Answer

Correct Answer: +

Note: This Question is unanswered, help us to find answer for this one

60. How would you convert a String to an Int?

Answer

Correct Answer: Integer.parseInt("21")

Note: This Question is unanswered, help us to find answer for this one

61. What type of variable can be assigned to only once?

Answer

Correct Answer: Final

Note: This Question is unanswered, help us to find answer for this one

62. Which access modifier makes variables and methods visible only in the class where they are declared?

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

63. Which is not a valid lambda expression?

Answer

Correct Answer: String a -> false;

Note: This Question is unanswered, help us to find answer for this one

64. Using Java's Reflection API, you can use _ to get the name of a class and _ to retrieve an array of its methods.

Answer

Correct Answer: This.getClass().getSimpleName(); this.getClass().getDeclaredMethods()

Note: This Question is unanswered, help us to find answer for this one

65. Java programmers commonly use design patterns. Some examples are the _, which helps create instances of a class, the _, which ensures that only one instance of a class can be created; and the _, which allows for a group of algorithms to be interchangeable.

Answer

Correct Answer: Static factory method; singleton; strategy pattern

Note: This Question is unanswered, help us to find answer for this one

66. How do you force an object to be garbage collected?

Answer

Correct Answer: Set object to null and call System.gc()

Note: This Question is unanswered, help us to find answer for this one

67. What kind of relationship does "extends" denote?

Answer

Correct Answer: Is-a

Note: This Question is unanswered, help us to find answer for this one

68. What is a valid use of the hashCode() method?

Answer

Correct Answer: Deciding if two instances of a class are equal

Note: This Question is unanswered, help us to find answer for this one

69. Which functional interfaces does Java provide to serve as data types for lambda expressions?

Answer

Correct Answer: Consumer, Predicate, Supplier

Note: This Question is unanswered, help us to find answer for this one

70. Declare and initialize an array of 10 ints.

Answer

Correct Answer: Int[] numbers = new int[10];

Note: This Question is unanswered, help us to find answer for this one

71. Which choice is a disadvantage of inheritance?

Answer

Correct Answer: Classes related by inheritance are tightly coupled to each other.

Note: This Question is unanswered, help us to find answer for this one

72. Which operator would you use to find the remainder after division?

Answer

Correct Answer: %

Note: This Question is unanswered, help us to find answer for this one

73. What language construct serves as a blueprint containing an object's properties and functionality?

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

74. Declare a variable that holds the first four digits of Π

Answer

Correct Answer: Double pi = 3.141;

Note: This Question is unanswered, help us to find answer for this one

75. Why are ArrayLists better than arrays?

Answer

Correct Answer: You don't have to decide the size of an ArrayList when you first make it.

Note: This Question is unanswered, help us to find answer for this one

76. Which keyword lets you use an interface?

Answer

Correct Answer: Implements

Note: This Question is unanswered, help us to find answer for this one

77. Normally, to access a static member of a class such as Math.PI, you would need to specify the class "Math". What would be the best way to allow you to use simply "PI" in your code?

Answer

Correct Answer: Add a static import.

Note: This Question is unanswered, help us to find answer for this one

78. Which keyword lets you call the constructor of a parent class?

Answer

Correct Answer: Super

Note: This Question is unanswered, help us to find answer for this one

79. If you encounter UnsupportedClassVersionError it means the code was ___ on a newer version of Java than the JRE ___ it.

Answer

Correct Answer: Compiled; executing

Note: This Question is unanswered, help us to find answer for this one

80. You get a NullPointerException. What is the most likely cause?

Answer

Correct Answer: The object you are using has not been instantiated.

Note: This Question is unanswered, help us to find answer for this one

81. How does the keyword volatile affect how a variable is handled?

Answer

Correct Answer: It will never be cached by the CPU.

Note: This Question is unanswered, help us to find answer for this one

82. Which type of variable keeps a constant value once it is assigned?

Answer

Correct Answer: Final

Note: This Question is unanswered, help us to find answer for this one

83. Which is the most reliable expression for testing whether the values of two string variables are the same?

Answer

Correct Answer: String1.equals(string2)

Note: This Question is unanswered, help us to find answer for this one

84. What method can be used to create a new instance of an object?

Answer

Correct Answer: Constructor

Note: This Question is unanswered, help us to find answer for this one

85. What statement returns true if "nifty" is of type String?

Answer

Correct Answer: "nifty" instanceof String

Note: This Question is unanswered, help us to find answer for this one

86. Object-oriented programming is a style of programming where you organize your program around _ rather than _ and data rather than logic.

Answer

Correct Answer: Objects; actions

Note: This Question is unanswered, help us to find answer for this one

87. Which statement is NOT true?

Answer

Correct Answer: An anonymous class does not require a zero-argument constructor.

Note: This Question is unanswered, help us to find answer for this one

88. The runtime system starts your program by calling which function first?

Answer

Correct Answer: Main

Note: This Question is unanswered, help us to find answer for this one

89. Fill in the blank to create a piece of code that will tell whether int0 is divisible by 5: Boolean isDivisibleBy5 = _____

Answer

Correct Answer: Int0 % 5 == 0

Note: This Question is unanswered, help us to find answer for this one

90. Which is the most up-to-date way to instantiate the current date?

Answer

Correct Answer: LocalDate.now()

Note: This Question is unanswered, help us to find answer for this one

91. By implementing encapsulation, you cannot directly access the class's _ properties unless you are writing code inside the class itself.

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

92. You have an ArrayList of names that you want to sort alphabetically. Which approach would NOT work?

Answer

Correct Answer: Names.sort(List.DESCENDING)

Note: This Question is unanswered, help us to find answer for this one

93. What does this code print? System.out.print("apple".compareTo("banana"));

Answer

Correct Answer: Negative number

Note: This Question is unanswered, help us to find answer for this one

94. How do you write a foreach loop that will iterate over ArrayListpencilCase?

Answer

Correct Answer: For (Pencil pencil : pencilCase) {}

Note: This Question is unanswered, help us to find answer for this one

95. Given the following definitions, which of these expression will NOT evaluate to true? Boolean b1 = true, b2 = false; int i1 = 1, i2 = 2;

Answer

Correct Answer: I2 && b1

Note: This Question is unanswered, help us to find answer for this one

96. How can you achieve runtime polymorphism in Java?

Answer

Correct Answer: Method overriding

Note: This Question is unanswered, help us to find answer for this one

97. Given the string "strawberries" saved in a variable called fruit, what would fruit.substring(2, 5) return?

Answer

Correct Answer: Raw

Note: This Question is unanswered, help us to find answer for this one

98. Data items you use in a call to a method are called ____.

Answer

Correct Answer: Arguments

Note: This Question is unanswered, help us to find answer for this one

99. A literal string is a(n) ____ object.

Answer

Correct Answer: Anonymous

Note: This Question is unanswered, help us to find answer for this one

100. Abc.compareto("aba") returns ________.

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

101. If a program compiles fine, but it produces incorrect result, then the program suffers __________.

Answer

Correct Answer: A logic error

Note: This Question is unanswered, help us to find answer for this one

102. In an interview, ____ limit or restrict the response.

Answer

Correct Answer: Closed-ended questions

Note: This Question is unanswered, help us to find answer for this one

103. You can use the ________ method to force one thread to wait for another thread to finish.

Answer

Correct Answer: Sleep(long milliseconds)

Note: This Question is unanswered, help us to find answer for this one

104. Java, c#, and vb.net are examples of ________.

Answer

Correct Answer: Object-oriented languages

Note: This Question is unanswered, help us to find answer for this one

105. On many keyboards, the break key is also the ____ key.

Answer

Correct Answer: Pause

Note: This Question is unanswered, help us to find answer for this one

106. To register a source for an action event with a handler, use ________.

Answer

Correct Answer: Source.setOnAction(handler)

Note: This Question is unanswered, help us to find answer for this one

107. The compiler checks ________.

Answer

Correct Answer: Syntax errors

Note: This Question is unanswered, help us to find answer for this one

108. The following code causes java to throw ________. int number = integer.max_value + 1;

Answer

Correct Answer: No exceptions

Note: This Question is unanswered, help us to find answer for this one

109. The class used as a basis for inheritance is the ____ class.

Answer

Correct Answer: Base

Note: This Question is unanswered, help us to find answer for this one

110. Polymorphism means ________.

Answer

Correct Answer: That a variable of supertype can refer to a subtype object

Note: This Question is unanswered, help us to find answer for this one

111. In java, boolean array elements automatically are assigned the value ____.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

112. If you attempt to add an int, a byte, a long, and a float, the result will be a ________ value.

Answer

Correct Answer: Double

Note: This Question is unanswered, help us to find answer for this one

113. In java, you use variables of type ____ to store integers, or whole numbers.

Answer

Correct Answer: Int

Note: This Question is unanswered, help us to find answer for this one

114. An immutable class cannot have ________.

Answer

Correct Answer: Public data fields

Note: This Question is unanswered, help us to find answer for this one

115. 3' - '2' + 'm' / 'n' is ________.

Answer

Correct Answer: 1

Note: This Question is unanswered, help us to find answer for this one

116. The capability to inherit from more than one class is called ____ inheritance.

Answer

Correct Answer: Multiple inheritance

Note: This Question is unanswered, help us to find answer for this one

117. An aggregation relationship is usually represented as __________ in ___________.

Answer

Correct Answer: A data field/the aggregating class

Note: This Question is unanswered, help us to find answer for this one

118. Declaring instance variables ________ is known as data hiding or information hiding.

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

119. You use the ____ function to return a portion of an array and assign it to another array.

Answer

Correct Answer: Array_slice()

Note: This Question is unanswered, help us to find answer for this one

120. The purpose of ____ is to set or change the values of data fields within the class.

Answer

Correct Answer: Set methods

Note: This Question is unanswered, help us to find answer for this one

121. The format specifier ________ is a placeholder for an int value.

Answer

Correct Answer: %d.

Note: This Question is unanswered, help us to find answer for this one

122. The calling method needs to understand only the ____ to the method that is called.

Answer

Correct Answer: Interface

Note: This Question is unanswered, help us to find answer for this one

123. Loop ____ is the technique of combining two loops into one.

Answer

Correct Answer: Fusion

Note: This Question is unanswered, help us to find answer for this one

124. Every object is a _____ of a more general class.

Answer

Correct Answer: Member

Note: This Question is unanswered, help us to find answer for this one

125. Division by zero is a ________ error that is caught when the program executes

Answer

Correct Answer: Runtime

Note: This Question is unanswered, help us to find answer for this one

126. Comparing a variable to a list of values in an array is a process called ____ an array.

Answer

Correct Answer: Searching

Note: This Question is unanswered, help us to find answer for this one

127. Before entering a loop, the first input statement, or ____, is retrieved.

Answer

Correct Answer: Priming read

Note: This Question is unanswered, help us to find answer for this one

128. A for loop provides a convenient way to create a(n) ____ loop.

Answer

Correct Answer: Counter-controlled

Note: This Question is unanswered, help us to find answer for this one

129. A class that represents the most general entity in an inheritance hierarchy is called a/an ____.

Answer

Correct Answer: Superclass.

Note: This Question is unanswered, help us to find answer for this one

130. A ________ method does not return a value.

Answer

Correct Answer: Void

Note: This Question is unanswered, help us to find answer for this one

131. Arguments to methods always appear within ________.

Answer

Correct Answer: Parentheses.

Note: This Question is unanswered, help us to find answer for this one

132. The ____ operator is always evaluated before the or operator.

Answer

Correct Answer: AND

Note: This Question is unanswered, help us to find answer for this one

133. The operators =, <, >, <=, >=, and <> are referred to as ____ operators.

Answer

Correct Answer: Single-row

Note: This Question is unanswered, help us to find answer for this one

134. The "less than or equal to" comparison operator in java is __________.

Answer

Correct Answer: <=

Note: This Question is unanswered, help us to find answer for this one

135. Data sent by a program to the screen, a printer, or a file is __________.

Answer

Correct Answer: Output

Note: This Question is unanswered, help us to find answer for this one

136. Ascii is able to encode a total of ____ different characters.

Answer

Correct Answer: 256

Note: This Question is unanswered, help us to find answer for this one

137. Variables declared within a button's click event handler are ________ variables.

Answer

Correct Answer: Local

Note: This Question is unanswered, help us to find answer for this one

138. The term ________ commonly is used to refer to a string that is part of another string.

Answer

Correct Answer: Substring

Note: This Question is unanswered, help us to find answer for this one

139. The size of ________ can grow and shrink at runtime.

Answer

Correct Answer: An ArrayList

Note: This Question is unanswered, help us to find answer for this one

140. The primitive data types only allow a(n) ________ to hold a single value.

Answer

Correct Answer: Variable

Note: This Question is unanswered, help us to find answer for this one

141. The not equal comparison operator in java is ________.

Answer

Correct Answer: !=

Note: This Question is unanswered, help us to find answer for this one

142. The length of a string can be determined by ________.

Answer

Correct Answer: The String method length()

Note: This Question is unanswered, help us to find answer for this one

143. The keyword ________ is required to declare a class.

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

144. Sql ________ statements may change the contents of a database.

Answer

Correct Answer: UPDATE
DELETE
INSERT

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

145. Invoking ________ removes all elements in an arraylist x.

Answer

Correct Answer: X.clear()

Note: This Question is unanswered, help us to find answer for this one

146. Information is passed to a method in ________.

Answer

Correct Answer: The arguments to the method

Note: This Question is unanswered, help us to find answer for this one

147. If a key is not in the list, the binarysearch method returns ________.

Answer

Correct Answer: (insertion point + 1)

Note: This Question is unanswered, help us to find answer for this one

148. A(n) ________ indicates a problem that occurs while a program executes.

Answer

Correct Answer: Exception

Note: This Question is unanswered, help us to find answer for this one

149. A variable or a value listed in a call to a method is called ________.

Answer

Correct Answer: An argument

Note: This Question is unanswered, help us to find answer for this one

150. A java virtual machine is actually a ________.

Answer

Correct Answer: Bytecode interpreter

Note: This Question is unanswered, help us to find answer for this one

151. ________ is a data structure to store data in sequential order.

Answer

Correct Answer: A list

Note: This Question is unanswered, help us to find answer for this one

152. Declaring main as ________ allows the jvm to invoke main without creating an instance of the class.

Answer

Correct Answer: Static

Note: This Question is unanswered, help us to find answer for this one

153. Some programmers refer to a catch block as a ____ clause.

Answer

Correct Answer: Clause

Note: This Question is unanswered, help us to find answer for this one

154. Local variables must be ________.

Answer

Correct Answer: Initialized before their values are used in expression

Note: This Question is unanswered, help us to find answer for this one

155. When you create an array of objects, each reference is assigned the value ____.

Answer

Correct Answer: Null

Note: This Question is unanswered, help us to find answer for this one

156. When they have the same name, variables within ____ of a class override the class’s fields.

Answer

Correct Answer: Methods

Note: This Question is unanswered, help us to find answer for this one

157. The purpose of a(n) ____ is to return a value to the world outside the class.

Answer

Correct Answer: Get method

Note: This Question is unanswered, help us to find answer for this one

158. The class ____ is the base of the classes designed to handle exceptions.

Answer

Correct Answer: Exception

Note: This Question is unanswered, help us to find answer for this one

159. The ________ method is used to display a message dialog.

Answer

Correct Answer: ShowMessageDialog

Note: This Question is unanswered, help us to find answer for this one

160. The ________ method immediately terminates the program.

Answer

Correct Answer: System.exit(0);

Note: This Question is unanswered, help us to find answer for this one

161. The ____ method converts any object to a string.

Answer

Correct Answer: ToString()

Note: This Question is unanswered, help us to find answer for this one

162. Methods that set values are called ____ methods.

Answer

Correct Answer: Mutator

Note: This Question is unanswered, help us to find answer for this one

163. Methods that retrieve values are called ____ methods.

Answer

Correct Answer: Accessor

Note: This Question is unanswered, help us to find answer for this one

164. If a number is too large to be stored in a variable of the float type, it ________.

Answer

Correct Answer: Causes overflow

Note: This Question is unanswered, help us to find answer for this one

165. Exceptions can be thrown by ________.

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

166. Exception handling helps you create ________ programs.

Answer

Correct Answer: Fault-tolerant

Note: This Question is unanswered, help us to find answer for this one

167. Every event object has the _____ method that returns the object that triggered the event.

Answer

Correct Answer: GetSource()

Note: This Question is unanswered, help us to find answer for this one

168. A(n) ____ is a variable that holds a memory address.

Answer

Correct Answer: Reference

Note: This Question is unanswered, help us to find answer for this one

169. A variable defined inside a method is referred to as ________.

Answer

Correct Answer: A local variable

Note: This Question is unanswered, help us to find answer for this one

170. A static method can ________.

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

171. The ____ method takes a string argument and returns its double value.

Answer

Correct Answer: ParseDouble

Note: This Question is unanswered, help us to find answer for this one

172. To append data to an existing file, you open it with the ____________ method.

Answer

Correct Answer: AppendText

Note: This Question is unanswered, help us to find answer for this one

173. A method must declare to throw ________.

Answer

Correct Answer: Checked exceptions

Note: This Question is unanswered, help us to find answer for this one

174. _______ is a construct that defines objects of the same type.

Answer

Correct Answer: A class

Note: This Question is unanswered, help us to find answer for this one

175. ________ algorithms are used to arrange random data into some order.

Answer

Correct Answer: Sorting

Note: This Question is unanswered, help us to find answer for this one

176. The iterator() method returns an instance of the ________ interface.

Answer

Correct Answer: Iterator

Note: This Question is unanswered, help us to find answer for this one

177. A return statement without any value can be used in ________.

Answer

Correct Answer: Void Method

Note: This Question is unanswered, help us to find answer for this one

178. You use a ____ statement within a try block to specify an error message.

Answer

Correct Answer: Throw

Note: This Question is unanswered, help us to find answer for this one

179. You use ________ to run a java program.

Answer

Correct Answer: Java interpreter

Note: This Question is unanswered, help us to find answer for this one

180. You can leave out the ____ statements in a switch structure.

Answer

Correct Answer: Break

Note: This Question is unanswered, help us to find answer for this one

181. When you return an array from a method, the method returns ________.

Answer

Correct Answer: Reference of the array

Note: This Question is unanswered, help us to find answer for this one

182. When you place a block within an if statement, it is crucial to place the ____ correctly.

Answer

Correct Answer: Curly braces

Note: This Question is unanswered, help us to find answer for this one

183. When you derive a class from an existing class, you ________ add new data and functions.

Answer

Correct Answer: May

Note: This Question is unanswered, help us to find answer for this one

184. When reading words using a scanner object's next method, ____.

Answer

Correct Answer: The program must discard white space characters at the beginning of the input before calling the next method.

Note: This Question is unanswered, help us to find answer for this one

185. When invoking a method with an object argument, ___________ is passed.

Answer

Correct Answer: Reference of the object

Note: This Question is unanswered, help us to find answer for this one

186. When calling this() from a constructor, it must be the ____ statement within the constructor.

Answer

Correct Answer: First

Note: This Question is unanswered, help us to find answer for this one

187. When an object of one class is a data field within another class, they are related by ____.

Answer

Correct Answer: Composition

Note: This Question is unanswered, help us to find answer for this one

188. When an object is passed as an argument, ________ is passed into the parameter variable.

Answer

Correct Answer: A reference to the object

Note: This Question is unanswered, help us to find answer for this one

189. When an exception occurs it is said to have been ________.

Answer

Correct Answer: Thrown

Note: This Question is unanswered, help us to find answer for this one

190. When an array is passed to a function, it is actually ________ the array that is/are passed.

Answer

Correct Answer: The starting memory address of

Note: This Question is unanswered, help us to find answer for this one

191. When an application is run, the method that must be executed first must be named ____.

Answer

Correct Answer: Main

Note: This Question is unanswered, help us to find answer for this one

192. When a method is declared with the ________ modifier, it cannot be overridden in a subclass.

Answer

Correct Answer: Final

Note: This Question is unanswered, help us to find answer for this one

193. When a method ____ another, it takes precedence over the method, hiding the original version.

Answer

Correct Answer: Overrides

Note: This Question is unanswered, help us to find answer for this one

194. When a character is stored in memory, it is actually the ________ that is stored.

Answer

Correct Answer: ASCII code

Note: This Question is unanswered, help us to find answer for this one

195. Variables defined in the method header are called ________.

Answer

Correct Answer: Formal Parameters

Note: This Question is unanswered, help us to find answer for this one

196. To use a public variable or method outside of its class, you must ____ the name.

Answer

Correct Answer: Qualify

Note: This Question is unanswered, help us to find answer for this one

197. To make an int a double you would use a ______.

Answer

Correct Answer: Double d = i

Note: This Question is unanswered, help us to find answer for this one

198. To assign a double variable d to a float variable x, you write ________.

Answer

Correct Answer: X=(float)d

Note: This Question is unanswered, help us to find answer for this one

199. The uml uses ________ before a member name to indicate that the member is public.

Answer

Correct Answer: +

Note: This Question is unanswered, help us to find answer for this one

200. The syntax ____ assigns a return value to a variable.

Answer

Correct Answer: *

Note: This Question is unanswered, help us to find answer for this one

201. The simplest statement you can use to make a decision is the ____ statement.

Answer

Correct Answer: If

Note: This Question is unanswered, help us to find answer for this one

202. The signature of a method consists of ________.

Answer

Correct Answer: Both a and b

Note: This Question is unanswered, help us to find answer for this one

203. The relationship created with composition is called a(n) ____ relationship.

Answer

Correct Answer: Has-a

Note: This Question is unanswered, help us to find answer for this one

204. The relationship between an interface and the class that implements it is ________.

Answer

Correct Answer: Inheritence

Note: This Question is unanswered, help us to find answer for this one

205. The purpose of the __________ is to get the first input value for the validation of a loop.

Answer

Correct Answer: Primary read

Note: This Question is unanswered, help us to find answer for this one

206. The methods for modifying element in the ________ class are synchronized.

Answer

Correct Answer: ArrayList

Note: This Question is unanswered, help us to find answer for this one

207. The method header of the equals() method within the string class is ____.

Answer

Correct Answer: Public Boolean Strings

Note: This Question is unanswered, help us to find answer for this one

208. Predefined types such as int, double, and char are ____ types.

Answer

Correct Answer: Value

Note: This Question is unanswered, help us to find answer for this one

209. One or more objects may be created from a(n)________.

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

210. Java uses ________ to reference the current object.

Answer

Correct Answer: Constructor

Note: This Question is unanswered, help us to find answer for this one

211. Java requires a ________ call for every object that's created.

Answer

Correct Answer: Constructor

Note: This Question is unanswered, help us to find answer for this one

212. In java, ________ must be declared before they can be used.

Answer

Correct Answer: Variables

Note: This Question is unanswered, help us to find answer for this one

213. If an exception occurs in a try-catch block, the code in the finally clause ________.

Answer

Correct Answer: Is executed

Note: This Question is unanswered, help us to find answer for this one

214. Every class in java, except ________, extends an existing class.

Answer

Correct Answer: Object

Note: This Question is unanswered, help us to find answer for this one

215. Assume s is "" abc "", the method ________ returns a new string ""abc"".

Answer

Correct Answer: S.trim()

Note: This Question is unanswered, help us to find answer for this one

216. To check whether a char variable ch is an uppercase letter, you write ________.

Answer

Correct Answer: (ch >= 'A' && ch <= 'Z')

Note: This Question is unanswered, help us to find answer for this one

217. A method that has no implementation is called a/an ____ method.

Answer

Correct Answer: Abstract

Note: This Question is unanswered, help us to find answer for this one

218. A method header is also called a(n) _____.

Answer

Correct Answer: Declaration

Note: This Question is unanswered, help us to find answer for this one

219. The system.currenttimemillis() returns ________.

Answer

Correct Answer: The current time in milliseconds since midnight, January 1, 1970 GMT (the Unix time)

Note: This Question is unanswered, help us to find answer for this one

220. The static method ________ of class string returns a formatted string.

Answer

Correct Answer: Format

Note: This Question is unanswered, help us to find answer for this one

221. The setonaction method is defined in ________.

Answer

Correct Answer: ButtonBase

Note: This Question is unanswered, help us to find answer for this one

222. The compiler determines which version of a method to call by the method?s ____.

Answer

Correct Answer: Signature

Note: This Question is unanswered, help us to find answer for this one

223. In java, the word true is ________.

Answer

Correct Answer: A Boolean literal

Note: This Question is unanswered, help us to find answer for this one

224. An indefinite loop is a(n) ____ loop

Answer

Correct Answer: Event controlled

Note: This Question is unanswered, help us to find answer for this one

225. A(n) ____ constructor is one that requires no arguments.

Answer

Correct Answer: Default

Note: This Question is unanswered, help us to find answer for this one

226. A javafx action event handler is an instance of ________.

Answer

Correct Answer: EventHandler

Note: This Question is unanswered, help us to find answer for this one

227. A javafx action event handler contains a method ________.

Answer

Correct Answer: Public void handle(ActionEvent e)

Note: This Question is unanswered, help us to find answer for this one

228. A java character is stored in ________.

Answer

Correct Answer: Two bytes

Note: This Question is unanswered, help us to find answer for this one

229. ________ represents an entity in the real world that can be distinctly identified.

Answer

Correct Answer: An object

Note: This Question is unanswered, help us to find answer for this one

230. ____ media files are accessed through a link that your web site visitor clicks.

Answer

Correct Answer: External

Note: This Question is unanswered, help us to find answer for this one

231. To obtain the current minute, use ________.

Answer

Correct Answer: System.currentTimeMillis() / 1000 / 60 % 60

Note: This Question is unanswered, help us to find answer for this one

232. The expression "java " + 1 + 2 + 3 evaluates to ________.

Answer

Correct Answer: Java123

Note: This Question is unanswered, help us to find answer for this one

233. Assume calendar calendar = new gregoriancalendar(). ________ returns the week of the year.

Answer

Correct Answer: Calendar.get(Calendar.WEEK_OF_YEAR)

Note: This Question is unanswered, help us to find answer for this one

234. Assume calendar calendar = new gregoriancalendar(). ________ returns the number of days in a month.

Answer

Correct Answer: Calendar.getActualMaximum(Calendar.DAY_OF_MONTH

Note: This Question is unanswered, help us to find answer for this one

235. Assume calendar calendar = new gregoriancalendar(). ________ returns the month of the year.

Answer

Correct Answer: Calendar.get(Calendar.MONTH)

Note: This Question is unanswered, help us to find answer for this one

236. When method printf requires multiple arguments, the arguments are separated with ________.

Answer

Correct Answer: Commas (,)

Note: This Question is unanswered, help us to find answer for this one

237. "abcdefgh".substring(1, 3) returns ________.

Answer

Correct Answer: Bc

Note: This Question is unanswered, help us to find answer for this one

238. You compare two strings s1 and s2 using ________.

Answer

Correct Answer: S1.compareTo(s2

Note: This Question is unanswered, help us to find answer for this one

239. If a programming language does not support ____, the language is not considered object-oriented.

Answer

Correct Answer: Polymorphism

Note: This Question is unanswered, help us to find answer for this one

240. You use the keyword ________ to reference a method in the superclass from a subclass.

Answer

Correct Answer: Super

Note: This Question is unanswered, help us to find answer for this one

241. To place two nodes node1 and node2 in a hbox p, use ________.

Answer

Correct Answer: P.getChildren().addAll(node1, node2)

Note: This Question is unanswered, help us to find answer for this one

242. To handle the mouse click event on a pane p, register the handler with p using ________.

Answer

Correct Answer: P.setOnMouseClicked(handler);

Note: This Question is unanswered, help us to find answer for this one

243. You use the _________ operator to access members of an object.

Answer

Correct Answer: .

Note: This Question is unanswered, help us to find answer for this one

244. To create an instance of bigdecimal for 454.45, use ________.

Answer

Correct Answer: New BigDecimal("454.45")

Note: This Question is unanswered, help us to find answer for this one

245. You can declare two variables with the same name in __________.

Answer

Correct Answer: Different methods in a class

Note: This Question is unanswered, help us to find answer for this one

246. Thread-local storage is data that ____.

Answer

Correct Answer: Is unique to each thread

Note: This Question is unanswered, help us to find answer for this one

247. A ____ is a structure that allows repeated execution of a block of statements.

Answer

Correct Answer: Loop

Note: This Question is unanswered, help us to find answer for this one

248. ____ variables are variables that are shared by every instantiation of a class.

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

249. ____ occurs when both of the operands are integers.

Answer

Correct Answer: Integer division

Note: This Question is unanswered, help us to find answer for this one

250. ____ is the process of ensuring that a value falls within a specified range.

Answer

Correct Answer: Data integrity

Note: This Question is unanswered, help us to find answer for this one

251. ____ is a complete programming language that can be used to create stand-alone applications.

Answer

Correct Answer: JAVA

Note: This Question is unanswered, help us to find answer for this one

252. The public constructors and methods of a class form the public _____ of the class.

Answer

Correct Answer: Interface

Note: This Question is unanswered, help us to find answer for this one

253. Static methods can only operate on ________ fields.

Answer

Correct Answer: Static

Note: This Question is unanswered, help us to find answer for this one

254. Math.pow(3, 3) returns ________.

Answer

Correct Answer: 27.0

Note: This Question is unanswered, help us to find answer for this one

255. Java uses class ________ to represent colors using their rgb values.

Answer

Correct Answer: Color

Note: This Question is unanswered, help us to find answer for this one

256. In java all output uses the ______ data type.

Answer

Correct Answer: String

Note: This Question is unanswered, help us to find answer for this one

257. Calculations are normally performed by ____________ statements.

Answer

Correct Answer: Assignment statements

Note: This Question is unanswered, help us to find answer for this one

258. An object is an instance of a ________.

Answer

Correct Answer: Class

Note: This Question is unanswered, help us to find answer for this one

259. All java applications must have a method ________.

Answer

Correct Answer: Public static void main(String[] args)

Note: This Question is unanswered, help us to find answer for this one

260. A final field should also be declared ________ if it is initialized in its declaration.

Answer

Correct Answer: Static

Note: This Question is unanswered, help us to find answer for this one

261. A constructor can access ________.

Answer

Correct Answer: A private instance variable

Note: This Question is unanswered, help us to find answer for this one

262. A class specifies the ________ and ________ that a particular type of object has.

Answer

Correct Answer: Fields; methods

Note: This Question is unanswered, help us to find answer for this one

263.

public class Test{

private int qusNo = 100;

}

What can directly access and change the value of the variable qusNo?


Answer

Correct Answer:

Only the Test class



Note: This Question is unanswered, help us to find answer for this one

264. What is the output of this program? class Upwork{ public static void main(String args[]) { int g = 3; System.out.print(++g * 8); } }

Answer

Correct Answer: 32

Note: This Question is unanswered, help us to find answer for this one

265. Which of the following are true?

Answer

Correct Answer: A local variable of type float defaults to 0.

Note: This Question is unanswered, help us to find answer for this one

266. Which implicit modifier is applied to all interface methods?

Answer

Correct Answer: public

Note: This Question is unanswered, help us to find answer for this one

267. Which of the following would be the correct way to compile and run a Java console application in file called App.java?

Answer

Correct Answer: javac App.java java App.java

Note: This Question is unanswered, help us to find answer for this one

268. Which of the following checks are performed by compiler when you override a nonprivate method?

Answer

Correct Answer: The method in the child class must have the same signature as the method in the parent class.
The method in the child class must be less accessible than the method in the parent class.
The method in the child class may not throw a checked exception that is new or braoder than the class of any exception thrown in the parent class method.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

269. What is the value of "d" after this line of code has been executed? double d=Math.round(2.5+Math.round());

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

270.

Which statement is true about the given code? public class Test78 { public static void main(String[] args) throws Exception { new JBean().setHeight(1).setWidth(2).setDepth(3).setDensity(9); } } class JBean { private int height, width, depth, density; public JBean setHeight (int h) { this.height = h; return this; } public JBean setWidth (int w) { this.width = w; return this; } public JBean setDepth (int d) { this.depth = d; return this; } public JBean setDensity (int d) { this.density = d; return this; } }

Answer

Correct Answer:

The code compiles and runs.



Note: This Question is unanswered, help us to find answer for this one

271.

What is the output of the given code? public class Test15 { public static void main(String[] args) { VO a = new VO(2); VO b = new VO(3); swapONE(a, b); print(a, b); swapTWO(a, b); print(a, b); } private static void print(VO a, VO b) { System.out.print(a.toString() + b.toString()); } public static void swapONE(VO a, VO b) { VO tmp = a; a = b; b = tmp; } public static void swapTWO(VO a, VO b) { int tmp = a.x; a.x = b.x; b.x = tmp; } } class VO { public int x; public VO(int x) { this.x = x; } public String toString() { return String.valueOf(x); } }

Answer

Correct Answer:

2332


Note: This Question is unanswered, help us to find answer for this one

272. Which type(s) cannot be used as generics?

Answer

Correct Answer: primitives
enum types

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

273.

Which of the following are true? (Choose all that apply) public class UpWork { public 

staic void main(String[] args) { UpWorkupw = new UpWork(); }}


Answer

Correct Answer:

Upwork is a class.



upw is a reference to an object.



Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

274. How we can make entity class or method final in JPA ?

Answer

Correct Answer: Neither entity class nor methods can be marked as final in JPA.

Note: This Question is unanswered, help us to find answer for this one

275. What is required for EJB asynchronous method?

Answer

Correct Answer: Method must return void or implementation of Future interface.

Note: This Question is unanswered, help us to find answer for this one

276. Which of the following are true? (Choose all that apply)

Answer

Correct Answer: An instance variable of type boolean defaults to false.
An instance variable of type int defaults to 0.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

277.

What would be the result of the following code? public class Quest { int i=0; public static void main(String argv[]) { } Quest() { top: while(i <2) { System.out.println(i); i++; continue top; } } }

Answer

Correct Answer:

The code will not compile as a target label cannot appear before the corresponding continue or break statement.



Note: This Question is unanswered, help us to find answer for this one

278.

What is the output of the given program? public class Test96 { public static void main(String[] args) { int[] a = new int[2]; System.out.println(a.length); } }

Answer

Correct Answer:

2


Note: This Question is unanswered, help us to find answer for this one

279.

Given the following class, which of the following is true? (Choose all that apply) 1: public class UpWork { 2: 3: public void freelancer(boolean time) { 4: 5: if (time) { 6: 7: } 8: System.out.println(result); 9: 10: } 11: }

Answer

Correct Answer: If String result = "job"; is inserted on line 2, the code will compile.
If String result = "job"; is inserted on line 4, the code will compile.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

280.

public interface Foo { int k = 4; /* Line 3 */ } Which three piece of codes are equivalent to line 3? 1, final int k = 4; public int k = 4; static int k = 4; abstract int k = 4; volatile int k = 4; protected int k = 4;

Answer

Correct Answer: 3, 4 and 5

Note: This Question is unanswered, help us to find answer for this one

281.

Which one of the following will declare an array and initialize it with five numbers?

Answer

Correct Answer: int [] a = {23,22,21,20,19};

Note: This Question is unanswered, help us to find answer for this one

282.

What is the purpose of a class constructor?

Answer

Correct Answer: To make objects initially have certain values when they are instantiated

Note: This Question is unanswered, help us to find answer for this one

283.

Which of the following snippets of code can be used to instantiate an object?

Answer

Correct Answer: Class A = new AClass();

Note: This Question is unanswered, help us to find answer for this one

284.

What will be the value of a? let a = -1 ? 'foo' ? null : -1 : 1;

Answer

Correct Answer: null

Note: This Question is unanswered, help us to find answer for this one

285.

Which statement is true for below code:- String s1 = "UpWork"; String s2 = "UpWork"; StringBuilder sb1 = new StringBuilder(); sb1.append("Up").append("Work"); System.out.println(s1 == s2); System.out.println(s1.equals(s2)); System.out.println(sb1.toString() == s1); System.out.println(sb1.toString().equals(s1));

Answer

Correct Answer: true is printed out exactly three times.

Note: This Question is unanswered, help us to find answer for this one

286.

Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

Answer

Correct Answer: java.lang.StringBuffer

Note: This Question is unanswered, help us to find answer for this one

287.

Which statement is true about the "switch" construct?

Answer

Correct Answer: The "default" statement will execute, if no matching "case" statement is found.

Note: This Question is unanswered, help us to find answer for this one

288.

Which of the following is the valid declaration of a method within an interface definition?

Answer

Correct Answer: public double methoda();

Note: This Question is unanswered, help us to find answer for this one

289.

Which of the following is a valid keyword in java?

Answer

Correct Answer: interface

Note: This Question is unanswered, help us to find answer for this one

290.

Which keyword prevents a class from being extended by another class?

Answer

Correct Answer: final

Note: This Question is unanswered, help us to find answer for this one

291.

Which of the following is the best way to compare the values stored in two objects?

Answer

Correct Answer: Overriding equals() Method

Note: This Question is unanswered, help us to find answer for this one

292.

Which of the following is a short circuit operator? (Check all that apply)

Answer

Correct Answer: &&
||

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

293.

What is TypeError?

Answer

Correct Answer: It's a human-friendly string with description about unexpected variable type used
It's an object with message parameter

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

294.

Which of the following is a valid declaration of a String?

Answer

Correct Answer: String s1 = null;

Note: This Question is unanswered, help us to find answer for this one

295.

Which of the following are correct Constructor Rules?

Answer

Correct Answer: The first statement of every constructor is a call to another constructor within the class using this(), or a call to a constructor in the direct parent class using super().

Note: This Question is unanswered, help us to find answer for this one

296.

Which is a reserved word in the Java programming language?

Answer

Correct Answer: native

Note: This Question is unanswered, help us to find answer for this one

297.

Which of the following is used to find out that a thread is still running?

Answer

Correct Answer: isAlive()

Note: This Question is unanswered, help us to find answer for this one

298.

Consider below code: class Ex1{ public static void main(String args[]){ int x = 10; int y = new Ex1().change(x); System.out.print(x+y); } int change(int x){ x=12; return x; } } What will be the output?

Answer

Correct Answer: 22

Note: This Question is unanswered, help us to find answer for this one

299.

What do JS classes support?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

300.

Which assignments are valid, if put instead of /* [placeholder] */ in the given code? (check any that apply)

public class Test114 {

 public static void main(String[] args) {

class A { class A2{}  }

class A2 extends A {}

/* [placeholder]   */

}

}

 

Answer

Correct Answer: A a = new A2();
A.A2 a = new A().new A2();
A.A2 a = new A2().new A2();

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

301.

Which of the following are valid ways to define a thread in Java?

Answer

Correct Answer: Create a subclass of java.lang.Thread class
Create a class that implements java.lang.Runnable

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

302.

Select all correct statements:

Answer

Correct Answer: Empty Java files compile without errors.
Importing java.lang package is not mandatory.
A Java source file that contains only import statements compiles without errors.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

303.

Which statement is false?

Answer

Correct Answer: When a subclass method with the same name and argument as its superclass is called, the superclass method is automatically called.

Note: This Question is unanswered, help us to find answer for this one

304.

What will be the output of the below code? class App{ public static void main(String[] args){ try{ System.out.print("1"); throw new Exception(); System.out.print("2"); } catch(Exception ex){ System.out.print("3"); throw ex; } } }

Answer

Correct Answer: Code will not compile

Note: This Question is unanswered, help us to find answer for this one

305.

What will be the output of the following program? class Upwork { public static void main(String args[]) { try { System.out.println("Hello World"); } finally { System.out.println("Finally executing"); } } }

Answer

Correct Answer: Hello World Finally executing

Note: This Question is unanswered, help us to find answer for this one

306.

What is the output of the given program? public class Test71 { public static void main(String[] args) { System.out.println(new Child().toString()); } } class Parent { public String toString() { return this.getClass().getName(); } } class Child extends Parent {}

Answer

Correct Answer: Child

Note: This Question is unanswered, help us to find answer for this one

307.

Which statement is true about the given program? public class Test25 { public static void main(String[] args) { final byte a = 20; final byte b = 4; final byte c = a + b; System.out.println(c); } }

Answer

Correct Answer: It compiles, runs, outputs 24 and exits.

Note: This Question is unanswered, help us to find answer for this one

308.

What will be the output when the following code is compiled and run? public class Test { public static void main(String args[]) { int i; i = 3; System.out.println((int) i * 2.5 / 3.0); } }

Answer

Correct Answer: The code will print 2.5.

Note: This Question is unanswered, help us to find answer for this one

309.

What is the output of the given console application? public class Main { public static void main(String[] args) { final int X = 9; int[][] a = {{5, 4, 3}, {9, 7, 2}, {1, 6, 8}}; for (int i=0; i<3; i++) { for (int j=0; j<3; j++) { if (a[i][j] == X) break; System.out.print(a[i][j] + " "); } } } }

Answer

Correct Answer: 5 4 3 1 6 8

Note: This Question is unanswered, help us to find answer for this one

310.

Which of the following keyword is used for manually throwing an exception?

Answer

Correct Answer: throw

Note: This Question is unanswered, help us to find answer for this one

311.

Which of the following statements are true? (Choose all that apply)

Answer

Correct Answer: An array has a fixed size.
An array allows multiple dimensions.
An array is ordered.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

312.

What is the output of the following program? class Upwork{ public static void main(String args[]) { int x , y; x = 10; x++; --x; y = x++; System.out.println(x + " " + y); } }

Answer

Correct Answer: 11 10

Note: This Question is unanswered, help us to find answer for this one

313.

Which of the following are valid java identifiers? (check any that apply)

A. Up$Work

B. _UpWork

C. true

D. Up.Work

E. Public

F. 1980_s

 

Answer

Correct Answer: Up$Work
_UpWork
Public

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

314.

We have a thread defined and running, which method is used to terminate its execution?

Answer

Correct Answer: interrupt

Note: This Question is unanswered, help us to find answer for this one

315.

Which three are valid declarations of a float? float f1 = -343; float f2 = 3.14; float f3 = 0x12345; float f4 = 42e7; float f5 = 2001.0D; float f6 = 2.81F;

Answer

Correct Answer: 2, 4, 6

Note: This Question is unanswered, help us to find answer for this one

316.

Which code will terminate the execution of a java program? (check any that apply)

Answer

Correct Answer: System.exit(0);
Runtime.getRuntime().exit(0);

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

317.

Which one of these lists contains only Java programming language keywords?

Answer

Correct Answer: goto, instanceof, native, finally, default, throws

Note: This Question is unanswered, help us to find answer for this one

318.

Which of the following are valid for an interface in Java?

Answer

Correct Answer: Interfaces cannot be instantiated directly.
An interface is not required to have any methods.
An interface may not be marked as final.
All top-level interfaces are assumed to have public or default access, and they must include the abstract modifier in their definition.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

319.

Which of the following is a method of a wrapper Integer for obtaining hash code for the invoking object?

Answer

Correct Answer: int hashCode()

Note: This Question is unanswered, help us to find answer for this one

320.

What is the output of the given program? public class Test122 { public static void main(String[] args) { int i = 0; i = i++; i = ++i; i = i++; System.out.println(i); } }

Answer

Correct Answer: 1

Note: This Question is unanswered, help us to find answer for this one

321.

What will be the output of following program? class Upwork { public static void main(String [] args) { int x = 0x80000000; System.out.print(x + " and "); x = x >>> 31; System.out.println(x); } }

Answer

Correct Answer: -2147483648 and 1

Note: This Question is unanswered, help us to find answer for this one

322.

What will be the output of following code? StringBuilder sb = new StringBuilder("UpWork"); sb.insert(6,"-"); sb.insert(0,"-"); sb.insert(4,"-"); System.out.println(sb);

Answer

Correct Answer: -UpW-ork-

Note: This Question is unanswered, help us to find answer for this one

323.

Which of the following statement is true about an anonymous inner class?

Answer

Correct Answer: It can extend exactly one class or can implement exactly one interface

Note: This Question is unanswered, help us to find answer for this one

324.

Which interface does java.util.Hashtable implement?

Answer

Correct Answer: java.util.Map

Note: This Question is unanswered, help us to find answer for this one

325.

Which of the following cannot directly cause a thread to stop executing?

Answer

Correct Answer: Calling notify() method on an object.

Note: This Question is unanswered, help us to find answer for this one

326.

Which of the following statement is an incorrect statement?

Answer

Correct Answer: StringBuffer calss is used to store string in a buffer for later use.

Note: This Question is unanswered, help us to find answer for this one

327.

You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?

Answer

Correct Answer: Protected

Note: This Question is unanswered, help us to find answer for this one

328.

Which of the following statements regarding abstract classes are true? (check any that apply)

Answer

Correct Answer: All methods declared in an abstract class must be abstract.
Any subclass (abstract or concrete class) of an abstract class must implement all the methods declared in the parent abstract class.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

329.

Is it possible to make entity as read only ?

Answer

Correct Answer: By making @org.hibernate.annotations.Entity(mutable = false).
Declare your fields as "protected" and provide only public getter.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

330.

What will be the output of following code:- List<String>upWork = new ArrayList<>(); upWork.add("jobs"); upWork.add(1, "freelancers"); upWork.add(0, "projects"); upWork.add(1, "earnings"); System.out.println(upWork);

Answer

Correct Answer: ["projects", "earnings", "jobs", "freelancers"]

Note: This Question is unanswered, help us to find answer for this one

331.

Which annotation helps to define the table where entity will be stored?

Answer

Correct Answer: @Table

Note: This Question is unanswered, help us to find answer for this one

332.

Assuming the tag library is in place and the tag handler is correct, which of the following is the correct way to use a custom tag in a JSP page?

Answer

Correct Answer: <yourLibrary:whatColorlslt color=»red»/>

Note: This Question is unanswered, help us to find answer for this one

333.

What will be the output of following program? class Upwork { public static void main(String args[]) { try { return; } finally { System.out.println("Finally"); } } }

Answer

Correct Answer: Finally

Note: This Question is unanswered, help us to find answer for this one

334.

What will be the output of following code? String string = "UpWork"; System.out.println(string.indexOf("o",5))?

Answer

Correct Answer: "-1"

Note: This Question is unanswered, help us to find answer for this one

335.

What is required for Message-Driven Bean?

Answer

Correct Answer: @MessageDriven annotation must be used
Class must be public

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

336.

Which of the following are known as runtime exceptions?

Answer

Correct Answer: ArithmeticException
ClassCastException

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

337.

Which three are valid declarations of a char? char c1 = 064770; char c2 = 'face'; char c3 = 0xbeef; char c4 = \u0022; char c5 = '\iface'; char c6 = '\uface';

Answer

Correct Answer: 1, 3, 6

Note: This Question is unanswered, help us to find answer for this one

338.

What is the output of the given program? public class Test115 { { System.out.print("_init"); } static { System.out.print("_static"); } public static void main(String[] args) { System.out.print("_main"); } }

Answer

Correct Answer: _static_main

Note: This Question is unanswered, help us to find answer for this one

339.

Which of the following programs will compile, run as a console application, and print the corresponding text to System.out?

Answer

Correct Answer: public class Test79a { public static void main(String[] args) throws Exception { System.out.println("Hello, 79a!"); } }
public class Test79b { final public static void main(String[] args) throws Exception { System.out.println("Hello, 79b!"); } }
public class Test79c { public static void main(String[] arguments) throws Exception { System.out.println("Hello, 79c!"); } }
public class Test79d { public static void main(String... args) throws Exception { System.out.println("Hello, 79d!"); } }

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

340.

Which will legally declare, construct, and initialize an array?

Answer

Correct Answer: int myList [] = {4, 3, 7};

Note: This Question is unanswered, help us to find answer for this one

341.

A method can be defined as native to: (choose all that apply)

Answer

Correct Answer: Get to access hardware that Java does not know about.
Write optimized code for performance in a language such as C/C++.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

342.

What will be the output of the following code? class ExceptionTest{ public static void main(String[] args){ try{ System.out.print("1"); throw new Exception(); } catch(Exception ex){ System.out.print("2"); } finally{ System.out.print("3"); } } }

Answer

Correct Answer: 123

Note: This Question is unanswered, help us to find answer for this one

343.

Which of the following are ignored by serialization? (Choose all that apply)

Answer

Correct Answer: Static fields
Transient fields

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

344.

What is the output of the following program? class Upwork { public static void main(String args[]) { try { int a[]={1,2,3,4,5}; for(int i=0;i<7;i++) System.out.println(a[i]); } catch(ArrayIndexOutOfBoundsException e) { System.out.println("0"); } } }

Answer

Correct Answer: 123450

Note: This Question is unanswered, help us to find answer for this one

345.

Which method contains the body of the thread?

Answer

Correct Answer: run()

Note: This Question is unanswered, help us to find answer for this one

346.

What will be the output of the following code? int three = 3; String four = "4"; System.out.println(1 + 2 + three + four); 

Answer

Correct Answer: "64"

Note: This Question is unanswered, help us to find answer for this one

347.

Which of these packages contain all the Java's built in exceptions? 

Answer

Correct Answer: java.lang

Note: This Question is unanswered, help us to find answer for this one

348.

Which of the following methods waits for the thread to terminate?

Answer

Correct Answer: join()

Note: This Question is unanswered, help us to find answer for this one

349.

What is the output of the following program?

Class Upwork{

Public static void main(string args[])

{

Byte x = 64;

Int I;

Byte y;

i = x << 2

y = (byte) (x << 2)

system.out.print(I + “” + y);

}

}

Answer

Correct Answer: 256 0

Note: This Question is unanswered, help us to find answer for this one

350.

Which type(s) cannot be used as generics?

Answer

Correct Answer: primitives

Note: This Question is unanswered, help us to find answer for this one

351.

What is the purpose of EL(Expression Language) in Java Web Application?

Answer

Correct Answer: Dynamically set/get JavaBean component data
Invoke JavaBean methods

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

352. What will be the output of following program? class Upwork { public static void  main(String args[]) { int x=100; double y=100.1; boolean b= (x=y); System.out.println(b); } }

Answer

Correct Answer: compilation fails

Note: This Question is unanswered, help us to find answer for this one

353.

Which of the following are true?

Answer

Correct Answer: The following classes compile. public class UpWork { public UpWork(int freelancers) { } } public class Developer extends UpWork { }

Note: This Question is unanswered, help us to find answer for this one

354.

What is the purpose java.exe?

Answer

Correct Answer: Compile .java files and run them

Note: This Question is unanswered, help us to find answer for this one

355.
Which method is used to pause thread execution for X seconds, so it might resume its
execution after that?

Answer

Correct Answer: sleep

Note: This Question is unanswered, help us to find answer for this one

356.
We are writing an application to manage auto parts. Auto part has String key as id.
Which collection will be the most efficient, if we are going to search parts by id?

Answer

Correct Answer: HashMap

Note: This Question is unanswered, help us to find answer for this one

357.

Which of the following statements regarding Java classes is true?

Answer

Correct Answer: A class provides the behavior and structure to create objects.

Note: This Question is unanswered, help us to find answer for this one

358.
Which of the following classes might be considered encapsulated: class Jason{ public
int age; public String name; } class Sam{ private int age; private String name; public
void setAge(int age){ this.age = age; } public intgetAge(){ return age; } public String 
getName(){ return name; } public void setName(String name){ this.name = name; } }

Answer

Correct Answer: Sam class is encapsulated.

Note: This Question is unanswered, help us to find answer for this one

359.

Which of the following will compile without any error?

Answer

Correct Answer: public abstract class UpWork { }

Note: This Question is unanswered, help us to find answer for this one

360.
Say we have java entity with date field. For example: @Entity class User{ private Date 
joinDate; public Date getJoinDate(){ return joinDate; } public void setJoinDate(Date
joinDate){ this.joinDate = joinDate; } } What JPA annotation will help us specify date
format that will be used in database?

Answer

Correct Answer: @Temporal

Note: This Question is unanswered, help us to find answer for this one

361.
Will the following code compile? public interface Repository{ void save(Object data); }
public abstract class RepositoryImpl implements Repository{ }

Answer

Correct Answer: No compilation error

Note: This Question is unanswered, help us to find answer for this one

362.

Is it possible to get mapping information from parent class that entity extends?

Answer

Correct Answer: Yes, @MappedSuperclass annotation is used.

Note: This Question is unanswered, help us to find answer for this one

363.

What kinds of properties can a JavaBean have?

Answer

Correct Answer: indexed properties
bound properties
constrained properties

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

364.
Which class method will be called under lines //Line 1 and //Line 2 in the following
code? class Rectangle { double width, length; Rectangle(double width, double length) {
this.width = width; this.length = length; } double getArea() { double area = width * length; 
return area; } void show() { System.out.println(""The width and length are: "" + width + "", 
"" + length); System.out.println(""The area is: "" + getArea()); } } class Square extends
Rectangle { double width, length; Square(double width) { super(width, width); this.width 
= width; } double getArea() { double area = width * width; return area; } void show() {
System.out.println(""The width is: "" + width); System.out.println(""The area is: "" + 
getArea()); } public static void main(String[] args) { Rectangle shape1 = new
Rectangle(5, 2); Square shape2 = new Square(5); shape1.show(); // Line 1
shape2.show(); // Line 2 } }

Answer

Correct Answer: shape1.show(); // Line 1 - Square Class Method Call shape2.show(); // Line 2 -Square Class Method Call

Note: This Question is unanswered, help us to find answer for this one

365.

Which tool has interface to trigger managed beans?

Answer

Correct Answer: java.exe

Note: This Question is unanswered, help us to find answer for this one

366.
Which statement is true about the given program? public class Test24 { public static 
void main(String[] args) { byte a = 20; byte b = 4; byte c = a + b; System.out.println(c); }
}

Answer

Correct Answer: It does not compile (compiler error).

Note: This Question is unanswered, help us to find answer for this one

367.

What is the difference between a try-catch block and a try-catch-finally block?

Answer

Correct Answer: try-catch contains code to execute if an error occurs or not, while try-catch-finally works the same way as try-catch block with the addition of a set of code that willexecute whether an error occurs or not.

Note: This Question is unanswered, help us to find answer for this one

368.

Which is the best place to store business logic and look of the page?

Answer

Correct Answer: Servlet must contain both display logic and business logic.

Note: This Question is unanswered, help us to find answer for this one

369.
The code below is supposed to find the maximum value of array 
{6,15,2,5,8,14,10,16,11,17,13,7,1,18,3,4,9,12}. How can the code be substantially
improved, if at all? public static intmaxOfArray(int[] a) { int length = a.length; if(length<1) 
throw new NoSuchElementException("Not at least one integer in array"); while (length >
1) { int k = length; for(inti = 0; i< length/2; i++) { k--; if(a[i]>a[k]) { int j = a[i]; a[i] = a[k];
a[k] = j; } } length /=2; } return a[0]; }

Answer

Correct Answer:

* (must fix if (a[i]>a[k]) to if (a[i]<a[k]))


Note: This Question is unanswered, help us to find answer for this one

370.
How can the string "1 2 3 3 4 4 5 1" be added to an ArrayList where each number
separated by a space is added as a separate list item, and the list cannot have
duplicates?

Answer

Correct Answer: Check if the ArrayList already contains the same string using the contains() method.

Note: This Question is unanswered, help us to find answer for this one

371.
The method foo() defined in the class Quiz has the following signature: public static 
double foo(double f) What can be said about foo()?

Answer

Correct Answer: It is a class method.

Note: This Question is unanswered, help us to find answer for this one

372.
What will be the output of the following code? public class Test extends Thread { private
int value; public Test(int value) { this.value = value; } public static void main(String[] 
args) { Test t1 = new Test(1); Test t2 = new Test(2); Test t3 = new Test(3); t1.start();
t2.start(); t3.start(); } @Override public void run() { for (inti = 0; i< 3; i++) {
System.out.println("Thread " + value + " with value " + i + " Started"); try { sleep(100); }
catch (InterruptedException ex) { 
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); }
System.out.println("Thread " + value + " with value " + i + " Completed"); } } }

Answer

Correct Answer: The output cannot be predicted.

Note: This Question is unanswered, help us to find answer for this one

373.

Which is the correct way to make the Jframevisiable always on top of other windows ?

Answer

Correct Answer: Jframe.setAlwaysOnTop(true);

Note: This Question is unanswered, help us to find answer for this one

374.

Which is a proper way to declare and throw exception of class XYException?

Answer

Correct Answer: class XYException extends Exception {} ... throw new XYException();

Note: This Question is unanswered, help us to find answer for this one

375.
What will be the output of the following code? public double beraknaOmkrets() {
DecimalFormat f = new DecimalFormat("##.0"); intradie = 3; double omkrets = 0;
omkrets = radie*2*3.14; return f.format(omkrets).toString; }

Answer

Correct Answer: It returns a compile time error.

Note: This Question is unanswered, help us to find answer for this one

376.

What is the numerical range of a char?

Answer

Correct Answer: 0 to 65535

Note: This Question is unanswered, help us to find answer for this one

377.

Is it possible to execute different threads in a user defined sequence in Java?

Answer

Correct Answer: It's possible using the "notify" method.

Note: This Question is unanswered, help us to find answer for this one

378.
What is the O(n) run-time of the following function? static int fib(int n){  if (n <= 
2)   return 1;  else return fib(n-1) + fib(n-2)  }

Answer

Correct Answer: O(2^n)

Note: This Question is unanswered, help us to find answer for this one

379.

Can one class in java extend multiple classes?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

380.

Which is the correct method to add button listener.

Answer

Correct Answer: jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { } });

Note: This Question is unanswered, help us to find answer for this one

381.

Which annotation makes a basic class persistent?

Answer

Correct Answer: @Entity

Note: This Question is unanswered, help us to find answer for this one

382.
Which of the following is the correct way in Java to show that the class Developer inherits from
the parent class Freelancer?

Answer

Correct Answer: public class Developer extends Freelancer { // Methods and variables defined here }

Note: This Question is unanswered, help us to find answer for this one

383.

Which of these is a process of converting a primitive data type into object?

Answer

Correct Answer: None of the above

Note: This Question is unanswered, help us to find answer for this one

384.

What is the output of the given program? public class Test109 { public static void main(String[] args) { System.out.println( 10/3 > 3 ? "MORE" : 10/4 < 3 ? "LESS" : "MORE" ); } }

Answer

Correct Answer: LESS

Note: This Question is unanswered, help us to find answer for this one

385.

Which of the following are among the rules for defining abstract methods?

Answer

Correct Answer: An abstract method must not provide a method body/implementation in the abstract class for which it is declared.

Note: This Question is unanswered, help us to find answer for this one

386.

Which is the valid declarations within an interface definition?

Answer

Correct Answer: public double methoda();

Note: This Question is unanswered, help us to find answer for this one

387.

Which method is used to wait for thread to fully complete its execution?

Answer

Correct Answer: join

Note: This Question is unanswered, help us to find answer for this one

388.

What allows the programmer to destroy an object x?

Answer

Correct Answer: Only the garbage collection system can destroy an object

Note: This Question is unanswered, help us to find answer for this one

389.

Which statement is true about a static nested class?

Answer

Correct Answer: It does not have access to non static members of the enclosing class.

Note: This Question is unanswered, help us to find answer for this one

390.

Which collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence?

Answer

Correct Answer: java.util.LinkedHashMap

Note: This Question is unanswered, help us to find answer for this one

391.

What is the prototype of the default constructor for following class? public class Test { }

Answer

Correct Answer: public Test( )

Note: This Question is unanswered, help us to find answer for this one

392.

What will be the output of following code: class Printer extends Thread{ private int max = 0; public Printer(int max){ this.max = max; } public void run() { for(int i=1; i<=max; i++){ System.out.println(i); } } public static void main(String[] args){ Printer printer1 = new Printer(3); Printer printer2 = new Printer(2); printer1.start(); printer2.start(); } }

Answer

Correct Answer: 1 2 1 2 3

Note: This Question is unanswered, help us to find answer for this one

393.

What modifers are implicitly applied to all interface methods? (Choose all that apply)

Answer

Correct Answer: static

Note: This Question is unanswered, help us to find answer for this one

394.

Which of the following class level (non local) variable declarations will not compile?

Answer

Correct Answer: private synchronized int e;

Note: This Question is unanswered, help us to find answer for this one

395.

Which of these method of Thread class is used to find out the priority given to a thread?

Answer

Correct Answer: getPriority()

Note: This Question is unanswered, help us to find answer for this one

396.

What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?

Answer

Correct Answer: default access

Note: This Question is unanswered, help us to find answer for this one

397.

Which of the following is not a valid collection class?

Answer

Correct Answer: HashList

Note: This Question is unanswered, help us to find answer for this one

398.

Consider the below statement:- String string = "UpWork"; Which of the following will output "o"?

Answer

Correct Answer: System.out.println(string.substring(3, 4));

Note: This Question is unanswered, help us to find answer for this one

399.

Which annotation is used to prevent entity field from being saved into the database?

Answer

Correct Answer: @Transient

Note: This Question is unanswered, help us to find answer for this one

400.

Which of the following can be used to bind HTML form parameters into Java EE web service method?

Answer

Correct Answer: @FormParam

Note: This Question is unanswered, help us to find answer for this one

401.

What will be the output of following program? public class UpWork { private String freelancer; private boolean busy: public static void main(String[] args) { UpWork upw = new UpWork(); System.out.print("Busy= " + upw.busy); System.out.print(", Freelancer = " + upw.freelancer); } }

Answer

Correct Answer: Busy = false, Freelancer = null

Note: This Question is unanswered, help us to find answer for this one

402.

Which one is a valid declaration of a boolean?

Answer

Correct Answer: boolean b3 = false;

Note: This Question is unanswered, help us to find answer for this one

403.

What is usually inside the WEB-INF folder of a typical Java Web Application?

Answer

Correct Answer: Compiled classes
Jar libraries
Deployment descriptors

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

404.

What is the output of the given code? final byte a = 12; final byte b = 5; System.out.println(a&b);

Answer

Correct Answer: 4

Note: This Question is unanswered, help us to find answer for this one

405.

Is it possible to ignore a field or fields during persistence ?

Answer

Correct Answer: By marking field or field @Transient it will ignore at the time of persistence.

Note: This Question is unanswered, help us to find answer for this one

406.

Which of the following can be used to inject URI query parameters into a Java method?

Answer

Correct Answer: @QueryParam

Note: This Question is unanswered, help us to find answer for this one

407.

Which method is used in every Java program?

Answer

Correct Answer: main()

Note: This Question is unanswered, help us to find answer for this one

408.

Which keyword is used for implementing an interface in a class?

Answer

Correct Answer: implements

Note: This Question is unanswered, help us to find answer for this one

409.

What is the internal implementation of ArrayList in Java?

Answer

Correct Answer: ArrayList internally uses array object to add the elements.

Note: This Question is unanswered, help us to find answer for this one

410.

What is the result of the following code? public class JQ { public static void main(String[] args) { f(); } private static void f() { f(); } }

Answer

Correct Answer: It compiles, runs without issues, but never ends, because there's an endless loop.

Note: This Question is unanswered, help us to find answer for this one

411.

What is the output of the given console application? public class Test34 { public static void main(String[] args) { int a = 2; switch(a) { default: System.out.print("_default"); case 0: System.out.print("_ZERO"); case 1: System.out.print("_ONE"); } } }

Answer

Correct Answer: _default_ZERO_ONE

Note: This Question is unanswered, help us to find answer for this one

412.

Which annotation defines unique identifier for a JPA entity?

Answer

Correct Answer: @Id

Note: This Question is unanswered, help us to find answer for this one

413.

Which of the following is the correct way to run a thread?

Answer

Correct Answer: Thread thread = new MyThread(); thread.start();

Note: This Question is unanswered, help us to find answer for this one

414.

Which JDK tool converts java file to bytecode?

Answer

Correct Answer: javac.exe

Note: This Question is unanswered, help us to find answer for this one

415.

What will be the output of following code: for(int i=1; i<10; i++){ System.out.print(" "+i); }

Answer

Correct Answer: 1 2 3 4 5 6 7 8 9

Note: This Question is unanswered, help us to find answer for this one

416.

Which of the following classes ease implementation of JavaBean properties?

Answer

Correct Answer: PropertyChangeSupport
VetoableChangeSupport

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

417.
What is the output of the given console application? public class Test18 { public static
void main(String[] args) { for (int i=0; i<7; i++) { if (i==4) continue; System.out.print(i); } }
}

Answer

Correct Answer: 012356

Note: This Question is unanswered, help us to find answer for this one

418.
What is the output of the given program? public class Test118 extends _Test118 { {
System.out.print("_INIT"); } static { System.out.print("_STATIC"); } Test118() {
System.out.print("_CONST"); } public static void main(String[] args) { 
System.out.print("_MAIN"); new Test118(); } } class _Test118 { _Test118() {
System.out.print("_BASE"); } }

Answer

Correct Answer: _STATIC_MAIN_BASE_INIT_CONST
_STATIC_MAIN_BASE_INIT_CONST

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

419.
What is the output of the given program? public class Test102 { public static void 
main(String[] args) { String s = "string102"; String t = "string" + (9 * s.length() + 3); String
u = "string" + 102; System.out.println( (s==t) + "-" + (s==u) ); } }

Answer

Correct Answer: false-true

Note: This Question is unanswered, help us to find answer for this one

420.
Which term refers to an application's ability to execute concurrent processes in a timely
manner?

Answer

Correct Answer: liveness

Note: This Question is unanswered, help us to find answer for this one

421.

Which Java EE framework is used to create REST web services?

Answer

Correct Answer: JAX-RS

Note: This Question is unanswered, help us to find answer for this one

422.

Which layout class would you use to lay out components from left to right?

Answer

Correct Answer: FlowLayout

Note: This Question is unanswered, help us to find answer for this one

423.
What is the output of the given program? import java.io.*; public class Test86 { public
static void main(String[] args) throws ClassNotFoundException, IOException {
ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ObjectOutputStream 
objStrm = new ObjectOutputStream(bOut); Beta b = new Beta() {{ a=2; b=3; }}; 
objStrm.writeObject(b); ObjectInputStream objInStrm = new ObjectInputStream(new
ByteArrayInputStream(bOut.toByteArray()));
System.out.println(objInStrm.readObject().toString()); } } class Alpha { public int a; public
transient int b; } class Beta extends Alpha implements Serializable { public String 
toString() { return String.valueOf(a) + String.valueOf(b); } }

Answer

Correct Answer: 00

Note: This Question is unanswered, help us to find answer for this one

424.

What's the output of the following code: int a = 5; while(a > 3){ System.out.print(a--); }

Answer

Correct Answer: 5 4

Note: This Question is unanswered, help us to find answer for this one

425.
What is the output of the given program? import java.util.Properties; public class Test72
{ public static void main(String[] args) { Properties p = new Properties(); p.put("grade",
"master"); Properties p2 = new Properties(p); System.out.println(p2.get("grade") + " : " +
p2.getProperty("grade")); } }

Answer

Correct Answer: null : master

Note: This Question is unanswered, help us to find answer for this one

426.
What will be the output of following code:- int a = 5; int b = a; a*=2; b+=1; 
System.out.println(a); System.out.println(b);

Answer

Correct Answer: 10 6

Note: This Question is unanswered, help us to find answer for this one

427.
What is the output of the given program? public class Test128 { public static void
main(String[] args) { A a = new A2(); B b = new B2(); System.out.println(a.a + b.b); } }
class A { int a = 1; } class A2 extends A { int a = 2; } class B { public int b = 1; } class B2
extends B { public int b = 2; }

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

428.
Which statement about the given code is true? import java.io.IOException; public class 
Test110 { public static void main(String[] args) { throwEx(new
IOException("unchecked")); } static void throwEx(Exception e) {
Test110.<RuntimeException> _throw(e); } static <E extends Exception> void
_throw(Exception e) throws E { throw (E) e; } }

Answer

Correct Answer: Exception instance of IOException is created as unchecked in the main() method.

Note: This Question is unanswered, help us to find answer for this one

429.

A class has two method implementations that will cause a compiler error. What is the reason for the compiler error? public static void flexiPrint(Object... data){} public static void flexiPrint(Object[] data){}

Answer

Correct Answer: The argument "Object..." is identical to argument Object[].

Note: This Question is unanswered, help us to find answer for this one

430.

Which code snippet below generates random numbers between 0 and 0.5?

Answer

Correct Answer: Random generator = new Random(); double num = generator.nextDouble() * 0.5;
Random generator = new Random(); double num = generator.nextDouble()/2;

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

431.

Which of the following are legal variable types in java?

Answer

Correct Answer: int
byte
String

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

432.

Consider below code: class Ex1{ public static void main(String[] args) { int a[] = { 1,2,053,4}; int b[][] = { {1,2,4} , {2,2,1},{0,43,2}}; System.out.print(a[3]==b[0][2] ); System.out.print(" " + (a[2]==b[2][1])); } } What is the result?

Answer

Correct Answer: true true

Note: This Question is unanswered, help us to find answer for this one

433.

What is the term for the scenario when the compiler infers the type of a wildcard?

Answer

Correct Answer: wildcard capture

Note: This Question is unanswered, help us to find answer for this one

434.

What is the term to describe a situation where two or more threads are blocked forever, waiting for each other?

Answer

Correct Answer: deadlock

Note: This Question is unanswered, help us to find answer for this one

435.

Which of the following is the name of the cookie used by Servlet Containers to maintain session information?

Answer

Correct Answer: SERVLETID
JSESSIONID

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

436.

When a servlet accepts call from a client, it receives:

Answer

Correct Answer: Two objects - ServletRequest&ServletResponse

Note: This Question is unanswered, help us to find answer for this one

437.

When a serializable object is passed to a remote method, it is:

Answer

Correct Answer: Copied to the server

Note: This Question is unanswered, help us to find answer for this one

438.

Which is the correct way to create a daemon/background thread in Java?

Answer

Correct Answer: Thread t = new Thread(); t.setDaemon(true); t.start();

Note: This Question is unanswered, help us to find answer for this one

439.

Distributed Computing in Java means:

Answer

Correct Answer: Objects on different machines working together

Note: This Question is unanswered, help us to find answer for this one

440.

What will be the output, if the following program is run? public class Test8 { public static void main(String[] args) { System.out.println(Math.sqrt(-4)); } }

Answer

Correct Answer: NaN

Note: This Question is unanswered, help us to find answer for this one

441.

What is the output of the given console application? public class Test28 { public static void main(String[] args) { Doc.test(); } } class Doc { public String summary() { return ""doc#""; } public static void test() { Doc[] docs = new Doc[] {new Doc(), new Spec()}; for (Doc d: docs) System.out.print(d.summary()); } } class Spec extends Doc { public String summary() { return ""spc#""; } }

Answer

Correct Answer: doc#doc#

Note: This Question is unanswered, help us to find answer for this one

442.

Consider the following code: MyClasscls = new MyClass("Test Class"); System.out.println(cls); What is the best implementation for printing "Test Class" to the output?

Answer

Correct Answer: Override the toString method in this class and return the string which passes in the constructor.

Note: This Question is unanswered, help us to find answer for this one

443.

Which terms are applicable to the given code? Select all that apply. abstract class Widget { public abstract void draw(); } class Clock extends Widget { public void draw() { // Clock implementation of draw() } } class NewsHeadlines extends Widget { public void draw() { // NewsHeadlines implementation of draw() } } class StockQuotes extends Widget { public void draw() { // StockQuotes implementation of draw() } } public class Test5 { public static void main(String[] args) { java.util.List widgets = new java.util.LinkedList(); widgets.add(new Clock()); widgets.add(new NewsHeadlines()); widgets.add(new StockQuotes()); for (Widget w : widgets) w.draw(); } }

Answer

Correct Answer: overriding
polymorphism

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

444.

Which of the following code snippets will convert variables from long to int and int to long?

Answer

Correct Answer: inti = 5, j = 10, a; double k = 15, l = 20, b; a = (int) (k + l); b = i + j;

Note: This Question is unanswered, help us to find answer for this one

445.

What would be the URL syntax for using third party drivers for establishing a connection with a DBMS having a subprotocol named "webx"?

Answer

Correct Answer: jdbc:webx:dsn name

Note: This Question is unanswered, help us to find answer for this one

446.

What is the name of the process conducted by a bean builder tool to determine properties, methods and events of a JavaBean?

Answer

Correct Answer: introspection

Note: This Question is unanswered, help us to find answer for this one

447.

Which of the following is not a Java keyword?

Answer

Correct Answer: wait

Note: This Question is unanswered, help us to find answer for this one

448.

Which of the following is true about the Java Cryptography Extension (JCE)?

Answer

Correct Answer: It is included with the Java 2 platform.

Note: This Question is unanswered, help us to find answer for this one

449.

A previously saved handle has to be retrieved from an EJBObject named 'bookEJBObject'. The following remote interface has been written to restart the processing for that particular request: 1. ObjectInputStream stream = 2.                newObjectInputStream(new FileInputStream(fileName)); 3. 4. Handle bookHandle = (Handle) stream.readObject(); 5. 6. BookRemoteInterfacebookEjbObject = (BookRemoteInterface) XX() ; Which of the following should be substituted to Method XX() on line 6?

Answer

Correct Answer: javax.rmi.PortableRemoteObject.narrow(bookHandle.getEJBObject(), BookRemoteInterface.class);

Note: This Question is unanswered, help us to find answer for this one

450.

Which statements are true regarding ServletContextInit Parameters in the deployment descriptor?

Answer

Correct Answer: They are set at deployment-time, but accessed at run-time.
They are set at deployment-time and can be updated at run-time.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

451.

Which two statements among the following apply to redirecting an HTTP request to another URL in JSP?

Answer

Correct Answer: The path must be relative.
The redirect method must be called before the response body is committed, otherwise an IllegalStateException is thrown.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

452.

An online shop employs a stateless session bean (named ‘Eshop’) to process the request. ‘Eshop’

Uses a declarative transaction management system. The following code is from the XML deployment descriptor file of the bean:

  1. <ejb-jar>
  2. <enterprise-beans>
  3. <session>
  4.                <ejb-name>Eshop</ejb-name>
  5.                <home>com. solution. EshopHome</home>
  6.                <remote>com. Solution. Eshop</remote>
  7.                <local>com. Solution. EshopLocalHome<.local-home>
  8.                <local>com. Solution. EshopLocal</local>
  9.                <ejb-class>com. Solution. eshopBean</ejb-class>
  10.  
  11.  
  12. </session>
  13. </enterprise-beans>
  14. </ejb-jar>

The session and transaction attributes are to be coded in the numbered 10 and 11. Which of the

Following options should be used to make the bean work as expected?

Answer

Correct Answer: <session-type>Stateless</session-type> <transaction-type>Container</transaction-type>
<session-type>Stateless</session-type> <transaction-type>Container</transaction-type>

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

453.

Which statements are true regarding using wildcards in java code that uses generics? Select all true statements.

Answer

Correct Answer: A wildcard with a lower bound can be used.
A wildcard with a upper bound can be used.
A wildcard with both a lower and upper bound can be used.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

454.

Which of the following Java technologies support transaction processing?

Answer

Correct Answer: JTS
JDBC

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

455.

What is the best way to return an array from a function?

Answer

Correct Answer: public String[] test(){ String i[] = new String[5]; return i; }

Note: This Question is unanswered, help us to find answer for this one

456.

An ArrayList can be shuffled using the Knuth shuffle method by calling Collections.shuffle() method and passing the ArrayList object to it. What is the best way to do a Knuth shuffle on a stack data structure?

Answer

Correct Answer: By using Collections.shuffle() and passing the Stack object to it, similar to ArrayList Knuth shuffle.

Note: This Question is unanswered, help us to find answer for this one

457.

Which code snipped is the best to check whether a String s contains text "oDesk"?

Answer

Correct Answer: if (s.equals("oDesk"))

Note: This Question is unanswered, help us to find answer for this one

458.

Which of the following statements are true regarding declaring a servlet instance in a deployment descriptor?

Answer

Correct Answer: The tags are nested within web-app> tags.
It specifies the fully qualified class name of the servlet.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

459.

Which of the following interfaces makes it possible for Java to save an object to a file and turn it into a data stream?

Answer

Correct Answer: java.io.Serializable

Note: This Question is unanswered, help us to find answer for this one

460.

What exception is thrown by this code, if arr[j]>arr[j+1]:

public static  void main(String[] args) {

int []arr={12,23,43,34,3,6,7,1,9,6};

        { 

int temp;

for (inti=0;i<arr.length;i++)

              { 

for (int j=0;j<arr.length-i;j++ )

                {

if (arr[j]>arr[j+1])

                 { 

temp=arr[j];

arr[j+1]=arr[j];

arr[j+1]=temp;

                  }

                }

              }

            }

for(inti=0; i<arr.length; i++)

         {

System.out.print(arr[i] + " ");

         }

    }

Answer

Correct Answer: ArrayIndexOutOfBoundException

Note: This Question is unanswered, help us to find answer for this one

461.

Which of the following code snippets will take transform input string "2012/06/05" to output string "05 - 06 - 2012"?

Answer

Correct Answer: String dateString = "2012/06/05"; Date date = new SimpleDateFormat("yyyy/MM/dd").parse(dateString); SimpleDateFormat sdf = new SimpleDateFormat("dd - MM - yyyy"); System.out.println(sdf.format(date));

Note: This Question is unanswered, help us to find answer for this one

462.

In generics code, the question mark (?) is called the?

Answer

Correct Answer: Wildcard

Note: This Question is unanswered, help us to find answer for this one

463.

Which of the following transaction modes are supported by Enterprise Java Beans?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

464.

Which of the following is true?

Answer

Correct Answer: Each registered name for a servlet is associated with one instance of the servlet.

Note: This Question is unanswered, help us to find answer for this one

465.

With regard to the passivation of beans, which of the following statements is incorrect? A. The process is possible in all the enterprise beans. B. It is accompanied by some vendor specific methods, which are similar to java serialization.

Answer

Correct Answer: A

Note: This Question is unanswered, help us to find answer for this one

466.

Which of the following are liveness problems of a concurrent application?

Answer

Correct Answer: deadlock

Note: This Question is unanswered, help us to find answer for this one

467.

Which distributed object technology is most appropriate for systems that consist entirely of Java objects?

Answer

Correct Answer: RMI

Note: This Question is unanswered, help us to find answer for this one

468.

What is the output of the given program? public class Test121 extends _Test121 { { System.out.print("_INIT"); } static { System.out.print("_STATIC"); } Test121() { System.out.print("_CONST"); } public static void main(String[] args) { new Test121(); System.out.print("_|"); new Test121(); } } class _Test121 { { System.out.print("_BIN"); } static { System.out.print("_START"); } _Test121() { System.out.print("_BASE"); } }

Answer

Correct Answer: _START_STATIC_BIN_BASE_INIT_CONST_|_INIT_CONST

Note: This Question is unanswered, help us to find answer for this one

469.

What would be the result when the given code is compiled and ran? public class Test99 { int main() { System.out.println("alpha"); return 0; } public static void main(String args) { System.out.println("beta"); } final static public void main(String[] s) { System.out.println("gamma"); } }

Answer

Correct Answer: compiles, runs, and prints "beta"

Note: This Question is unanswered, help us to find answer for this one

470.

What is the best way to access a HashMap of SortedSet entries?

Answer

Correct Answer: Map String, SortedSet String>>makeSetMap = new HashMap String, SortedSet String>>(); for (String key : makeSetMap.keySet()) { // loop through all manufacturers SortedSet String> cars = makeSetMap.get(key); for (String c : cars) { // loop through all cars of that key System.out.println(key + " " + c); } }

Note: This Question is unanswered, help us to find answer for this one

471.

What is the result of compiling and running the given code? public class Test75 { public static void main(String[] args) { System.out.println(new A(){{}}.toString()); } } class A { public String toString() { return getClass().getName(); } }

Answer

Correct Answer: It compiles, but throws NullPointerException at run-time.

Note: This Question is unanswered, help us to find answer for this one

472.

In an RMI application, network data destined for a particular object received by an object is known as:

Answer

Correct Answer: Stub object

Note: This Question is unanswered, help us to find answer for this one

473.

The EJB specification defines six distinct roles in the application development and deployment life cycle. Which of the following roles is not mentioned in it?

Answer

Correct Answer: EJB Developer

Note: This Question is unanswered, help us to find answer for this one

474.

What is needed to define a property of a JavaBean?

Answer

Correct Answer: supply public getter and setter methods

Note: This Question is unanswered, help us to find answer for this one

475.

Which of the following are "keywords" in Java?

Answer

Correct Answer: default
throws

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

476.

Which code snippet will check for the existence of the file «text.txt» in the current location?

Answer

Correct Answer: File f = new File(); f.setName(«text.txt»); System.out.println(f.exists());

Note: This Question is unanswered, help us to find answer for this one

477.

What is the easiest and fastest way to sort the following string array?
String[] myString = {"cat","lion", "dog", "mouse"}

Answer

Correct Answer: Collections.Sort(myString);

Note: This Question is unanswered, help us to find answer for this one

478.

Consider the following code: public class Jam { public void apple(int i, String s) { } //ABC } Choose possible valid code replacements of "//ABC" among the choices:

 

Answer

Correct Answer: public void apple(String s, int i) {}
public void Apple(int i, String s) {}

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

479.

The JDK comes with a special program that generates skeleton and stub objects that is known as:

Answer

Correct Answer: rmic

Note: This Question is unanswered, help us to find answer for this one

480.

Which of the following correctly creates a thread using Runnable()?

Answer

Correct Answer: Runnable r = new Runnable(new Thread({ public void run(){ } })); r.run();

Note: This Question is unanswered, help us to find answer for this one

481.

1 <libraryPrefix:handlerName parameterNAme="value"> 2 <%=23*counter %> 3 <b>Congratulations!</b> Which of the following is the correct way to complete the code snippet above?

Answer

Correct Answer: </libraryPrefix:handlerName>

Note: This Question is unanswered, help us to find answer for this one

482.

Which of the following is true regarding DDL statements?

Answer

Correct Answer: DDL statements are a portion of the SQL standard that is concerned with the creation, deletion and modification of database objects like tables.
DDL statements are a portion of the SQL standard is concerned with manipulating the data in a database.
DDL statements cannot be rolled back.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

483.

Assuming the custom tag is GLOOP and the prefix is TWONG, which of the following is the correct JSP syntax for an empty custom tag?

Answer

Correct Answer: <GLOOP:TWONG></GLOOP:TWONG>
<TWONG:GLOOP></TWONG:GLOOP>

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

484.

What is the output of the given console application? public class Test31 { public static void main(String[] args) { test(); } public static void test() { try { System.out.print("-try"); return; } catch (Exception e) { System.out.print("-catch"); } finally { System.out.print("-finally"); } } }

Answer

Correct Answer: -try-finally

Note: This Question is unanswered, help us to find answer for this one

485.

Which of the following will programmatically throw an exception?

Answer

Correct Answer: throw new Exception();

Note: This Question is unanswered, help us to find answer for this one

486.

Assuming there is database recovery/backup system in place, which of the following statements is true with regard to committed and uncommitted data of entity beans?

Answer

Correct Answer: Both committed and uncommitted data will survive a server crash if clustering is used.

Note: This Question is unanswered, help us to find answer for this one

487.

Which exception must a setter of a constrained JavaBean property throw to prevent the property value from changing?

Answer

Correct Answer: PropertyVetoException

Note: This Question is unanswered, help us to find answer for this one

488.

Which of the following is the best option for scaling existing an application due to resource requirements, without changing its code?

Answer

Correct Answer: Moving business objects to the client's RAM

Note: This Question is unanswered, help us to find answer for this one

489.

Which of the following statements are true regarding the structure of a WebArchive file?

Answer

Correct Answer: It has a WAR extension.
It is extracted by the container upon the first call to any servlet it contains.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

490.

Which of the following statements regarding Enterprise Java Beans is incorrect?

Answer

Correct Answer: Message beans send synchronous messages.

Note: This Question is unanswered, help us to find answer for this one

491.

Which method in the HttpServlet class corresponds to the HTTPPUT method?

Answer

Correct Answer: put

Note: This Question is unanswered, help us to find answer for this one

492.

With regard to the destroy lifecycle method, identify the correct statements about its purpose or about how and when it is invoked.

Answer

Correct Answer: It gives the servlet an opportunity to clean up resources.
It is rarely used but can be called to remove a servlet from memory.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

493.

Which of the following is false?

Answer

Correct Answer: A while loop can be used because next () & previous () methods return -1 beyond the resultset.

Note: This Question is unanswered, help us to find answer for this one

494.

Select all true statements:

Answer

Correct Answer: Methods and variables can be declared final.
A class can be declared as final abstract.
Abstract methods can be overridden.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

495.

Which of the following is not a tier of three-tier architecture?

Answer

Correct Answer: Security

Note: This Question is unanswered, help us to find answer for this one

496.

Consider the following code: public static void main(String bicycle[]) { System.out.println(bicycle[0]); } What would be the result if "java TwoTyre one two" is entered in the command line?

Answer

Correct Answer: one

Note: This Question is unanswered, help us to find answer for this one

497.

Given a method declared as:

public static List process(List nums)

A programmer wants to use the method like this:

// INSERT DECLARATIONS HERE

output = process(input);

Which pair of declarations could be placed at // INSERT DECLARATIONS HERE to allow the code to compile? (Choose all that apply.)

Answer

Correct Answer: ArrayList<Integer> input = null; ArrayList<Integer> output = null;

ArrayList<Integer> input = null; List<Integer> output = null;


Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

498.

Which of the following code snippets will correctly convert from one time zone to another time zone?

Answer

Correct Answer: DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); formatter.setTimeZone(TimeZone.getTimeZone("GMT-8")); Date date = formatter.parse("01/01/2012 05:00:00"); System.out.println(formatter.format(date)); formatter.setTimeZone(TimeZone.getTimeZone("GMT+5")); System.out.println(formatter.format(date));
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); formatter.setTimeZone(new TimeZone("GMT-8")); Date date = formatter.parse("01/01/2012 05:00:00"); System.out.println(formatter.format(date)); formatter.setTimeZone(new TimeZone("GMT+5")); System.out.println(formatter.format(date));

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

499.

What is/are the OOP concepts demonstrated by this code:

public class Test {

public static void main(String[] args){

        Animal a = new Dog();

new Hospital().treatAnimal(a);

    }

}

class Animal {

public void sayIt(){

    }

}

class Dog extends Animal{

public void sayIt(){

System.out.println("I am Dog");

    }

}

class Cat extends Animal{

public void sayIt(){

System.out.println("I am Cat");

    }

}

class Hospital{

public void treatAnimal(Animal a){

if(a instanceof Dog){            

a.sayIt();

        } else {

a.sayIt();  

        }

    }

}

Answer

Correct Answer: Polymorphism

Note: This Question is unanswered, help us to find answer for this one

500.

What will happen to the running session beans if the EJB container crashes or restarts?

Answer

Correct Answer: They will be destroyed.

Note: This Question is unanswered, help us to find answer for this one

501.

What is the central abstraction of the Java Servlet API?

Answer

Correct Answer: The Servlet interface

Note: This Question is unanswered, help us to find answer for this one

502.

Which of the following is true regarding sleep() and wait() in threaded environments?

Answer

Correct Answer: The sleep() method will wait for a specific time (in milliseconds) and continue execution afterwards, while wait() will wait for another thread’s notify() method before it will execute.

Note: This Question is unanswered, help us to find answer for this one

503.

Which of the following symbols are metacharacters supported by the java.util.regex API?

Answer

Correct Answer: .
\

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

504.

What is the output of the given program?

 

public class Test117 {

{

System.out.print(«_INIT»);

}

static {

System.out.print(«_STATIC»);

}

Test117() {

System.out.print(«_CONST»);

}

public static void main(String[] args) {

System.out.print(«_MAIN»);

new Test117();

}

}

Answer

Correct Answer: _STATIC_MAIN_INIT_CONST

Note: This Question is unanswered, help us to find answer for this one

505.

Assuming the servlet method for handling HTTPGET requests is doGet(HttpServletRequest req, HTTPServletResponse res), how can the request parameter in that servlet be retrieved?

Answer

Correct Answer: String value=req.getParameter(«product»);

Note: This Question is unanswered, help us to find answer for this one

506.

Why can’t a string’s compareTo method be overridden?

Answer

Correct Answer: The String class is final, therefore its methods can’t be overridden.

Note: This Question is unanswered, help us to find answer for this one

507.

Which of the following methods can be used for reporting a warning on a Connection object, Statement object & ResultSet object?

Answer

Correct Answer: getWarnings()

Note: This Question is unanswered, help us to find answer for this one

508.

Which of the following is a well-known HTTP port?

Answer

Correct Answer: 80

Note: This Question is unanswered, help us to find answer for this one

509.

Which distributed object technology is most appropriate for systems that consist of objects written in different languages and that execute on different operating system platforms?

Answer

Correct Answer: CORBA

Note: This Question is unanswered, help us to find answer for this one

510.

What is the output of the given program?

public class Test89 {

public static void main(String[] args) {

T x = new T(«X», null); x.start();

T y = new T(«Y», x); y.start();

T z = new T(«Z», y); z.start();

}

}

class T extends Thread {

private Thread predecessor;

private String name;

public T(String name, Thread predecessor) {

this.predecessor = predecessor;

this.name = name;

}

public void run() {

try {

Thread.sleep((int)(Math.random()*89));

System.out.print(name);

} catch (InterruptedException ie) {

ie.printStackTrace();

}

}

}

Answer

Correct Answer: any of the following: XYZ, XZY, YXZ, YZX, ZXY, ZYX

Note: This Question is unanswered, help us to find answer for this one

511.

Which of the following methods should be invoked by the container to get a bean back to its working state?

Answer

Correct Answer: EJBActivate()

Note: This Question is unanswered, help us to find answer for this one

512.

With regard to the servlet context listener, which of the following methods is valid?

Answer

Correct Answer: contextInitialized

Note: This Question is unanswered, help us to find answer for this one

513.

Which is the right syntax of a javadoc comment for parameter of the method test(int)?

public class Test125 {

public static void main(String[] args) {

new Test125().test(125);

}

public void test(int a) {

for (int i=0; i<a; System.out.println(i++));

}

}

Answer

Correct Answer: @param a Description

Note: This Question is unanswered, help us to find answer for this one

514.

The transaction attribute of a bean is set to 'TX_REQUIRES_NEW.' What can be inferred about its behavior?

Answer

Correct Answer: The bean manages its own transaction.

Note: This Question is unanswered, help us to find answer for this one

515.

SQLException has a feature of chaining — identify the right code to execute the same from the following:

Answer

Correct Answer: catch(SQLException e) { out.println(e.getMessage()); while((e=e.getNextException())!=null) { out.println(e.getMessage()); } }

Note: This Question is unanswered, help us to find answer for this one

516.

Which of the following is the correct syntax for creating a Session object?

Answer

Correct Answer: HttpSession ses=request.getSession(true);
HttpSession ses=request.getSession();

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

517.

 The principal finder method that must be implemented by every entity bean class is:

Answer

Correct Answer: findByPrimaryKey()

Note: This Question is unanswered, help us to find answer for this one

518.

Why would the following code snippet not compile successfully?

if (mangoList instanceof List<Mango>) { System.out.println(«true»); }

Answer

Correct Answer: Generic types are erased before runtime.

Note: This Question is unanswered, help us to find answer for this one

519.

Consider the following:

 String sub ="hello".substring(2, 3);

 What is the value of sub?

Answer

Correct Answer: ''l''

Note: This Question is unanswered, help us to find answer for this one

520.

What would happen on compiling and running the following code?

 public class Test
 {
     public static void main (String args[])
     {
     TestThread t = new TestThread ();
     t.setValue (5);
     t.start ();
     t.setValue (10);
     }
 }
class TestThread extends Thread
     {
     private int value;
     synchronized public void setValue (int v)
     {
         value = v;
     }
     public void run ()
     {
     System.out.println ("before: " + value);
     setValue (50);
     System.out.println ("after: " + value);
     }
 }

Answer

Correct Answer: When run, this code will always print ''before: 5'' and ''after: 10''

Note: This Question is unanswered, help us to find answer for this one

521.

Can Java be used to send ICMP packets?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

522.

Which of these interfaces is the most applicable when creating a class that associates a set of keys with a set of values?

Answer

Correct Answer: Map

Note: This Question is unanswered, help us to find answer for this one

523.

How does the set collection deal with duplicate elements?

Answer

Correct Answer: The add method returns false if you attempt to add an element with a duplicate value

Note: This Question is unanswered, help us to find answer for this one

524.

For a class defined inside a method, what rule governs access to the variables of the enclosing method?

Answer

Correct Answer: The class can only access final variables

Note: This Question is unanswered, help us to find answer for this one

525.

Is the following code valid?

InetAddress ad = InetAddress.getByName ("195.186.2.111");

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

526.

How many objects are created by the following code?

 Object a, b, c, d, e;
 e = new Object ();
 b = a = e;
 e = new Object ();

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

527.

What is Abstraction?

Answer

Correct Answer: An act of representing essential features without including details or working methodology

Note: This Question is unanswered, help us to find answer for this one

528.

Which of the following will ensure that garbage collection runs?

Answer

Correct Answer: None of the above

Note: This Question is unanswered, help us to find answer for this one

529.

Which of the following will ensure that garbage collection runs? 

Answer

Correct Answer: The code will throw an exception as records are being printed after the connection is closed

Note: This Question is unanswered, help us to find answer for this one

530.

Which sequence will be printed when the following program is run?

 import java.util.*;
 public class Test
 {
 public static void main(String str[])
 {
 List l = new ArrayList();
 l.add(''1'');
 l.add(''2'');
 l.add(1,''3'');
 System.out.println(l);
 }
 }

Answer

Correct Answer: [1, 3, 2]

Note: This Question is unanswered, help us to find answer for this one

531.

Which of the following statements are correct?

Answer

Correct Answer: A class is an instance factory
A class is a template for creating an entity
A class is a set of all the instances of a pattern

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

532.

What would happen on trying to compile and run the following code?

 public class Test
 {
 public static void main (String args[])
 {
 int iRand;
 iRand = Math.random();
 System.out.println(iRand);
 }
 }

Answer

Correct Answer: A compilation error referring to a cast problem

Note: This Question is unanswered, help us to find answer for this one

533.

How many times can classes be nested within a class?

Answer

Correct Answer: Any number of times

Note: This Question is unanswered, help us to find answer for this one

534.

What is printed to the standard output if myMethod() is executed?

class MyPoint { 
  void myMethod() { 
     int x, y;
     x = 5; y = 3;
     System.out.print( " ( " + x + ", " + y + " ) " );
     switchCoords( x, y );
     System.out.print( " ( " + x + ", " + y + " ) " );
  }
  void switchCoords( int x, int y ) { 
     int temp;
     temp = x;
     x = y;
     y = temp;
     System.out.print( " ( " + x + ", " + y + " ) " );
  }
}

Answer

Correct Answer: (5, 3) (3, 5) (5, 3)

Note: This Question is unanswered, help us to find answer for this one

535.

Choose the correct declarations for the main() method which will allow the class to be run as a standalone program:

Answer

Correct Answer: static public void main(String str[])
public static void main(String str[])

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

536.

What is the method by which two or more applets can communicate with each other within one HTML page?

Answer

Correct Answer: getAppletContext()

Note: This Question is unanswered, help us to find answer for this one

537.

What will be the output when this code is compiled and run?

 public class Test
 {
 static int x = 10;
 public Test ()
 {
 Bar b = new Bar ();
 Bar b1 = new Bar ();
 update (b);
 update (b1);
 }
 private void update (Bar bar)
 {
 bar.x = ++x;
 System.out.println (bar.x);
 }
 public static void main (String args[])
 {
 new Test ();
 }
 private class Bar
 {
 public int x = 10;
 }
 }

Answer

Correct Answer: 11 12

Note: This Question is unanswered, help us to find answer for this one

538.

Which of these is not an event listener adapter defined in the java.awt.event package?

Answer

Correct Answer: ActionAdapter

Note: This Question is unanswered, help us to find answer for this one

539.

Can InetAddress be used with inet6?

Answer

Correct Answer: Yes
No, InetAddress is an abstract class

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

540.

Object.hashCode () will always return the same value for a given object. This is consistent from one execution of an application to another execution of the same application.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

541.

What will be the output when this code is compiled and run?

 public class Test
 {
 public Test ()
 {
 Bar b = new Bar ();
 Bar b1 = new Bar ();
 update (b);
 update (b1);
 b1 = b;
 update (b);
 update (b1);
 }
 private void update (Bar bar)
 {
 bar.x = 20;
 System.out.println (bar.x);
 }
 public static void main (String args[])
 {
 new Test ();
 }
 private class Bar
 {
 int x = 10;
 }
 }

Answer

Correct Answer: 20 20 20 20

Note: This Question is unanswered, help us to find answer for this one

542.

What would happen on compiling and running the following code?

 public class Anchor
 {
 public static void main(String[] argv)
 {
 new Anchor();
 }
 public Anchor()
 {
 String s[][] = new String[2][2];
 System.out.println(s[1][1]);
 System.out.println(s[1][2]);
 }
 }

Answer

Correct Answer: Compiles and prints null followed by ArrayIndexOutOfBoundsException

Note: This Question is unanswered, help us to find answer for this one

543.

What happens on attempting to compile and run the following code?

 public class Graft
 {
 public static void main(String argv[])
 {
 Graft g = new Graft();
 }
 protected Graft()
{
 for(int i =0; i <10; i ++)
 {
 System.out.println(i);
 }
 }
 }

Answer

Correct Answer: Successful compilation with output 0 to 9

Note: This Question is unanswered, help us to find answer for this one

544.

Which of the following are the methods of the Thread class?

Answer

Correct Answer: yield()
sleep(long millis)

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

545.

In which class is the notify method defined?

Answer

Correct Answer: Object

Note: This Question is unanswered, help us to find answer for this one

546.

What will be the output when this code is compiled and run?

 public class Test
 {
 static int a;
 int b;
 public Test ()
 {
 int a, b, c;
 a = b = c = 20;
 System.out.println (a);
 }
 public static void main (String args[])
 {
 new Test ();
 }
 }

Answer

Correct Answer: 20 is printed

Note: This Question is unanswered, help us to find answer for this one

547.

Which of the following statements is not correct with regard to threads in Java?

Answer

Correct Answer: The wait and notify methods are defined in the Thread class

Note: This Question is unanswered, help us to find answer for this one

548.

Select the correct option based upon the following sample code:

 public class Test
 {
 static int a;
 int b;
 public Test ()
 {
 int c;
 c = a;
 a++;
 b += c;
 System.out.println ("one");
 }
 public void Test ()
 {
 int c;
 c = a;
 a++;
 b += c;
 System.out.println ("two");
 }
 public static void main (String args[])
 {
 Test t = new Test ();
 }
 }

Answer

Correct Answer: The code will compile and run successfully. It will print ''one''

Note: This Question is unanswered, help us to find answer for this one

549.

What is Encapsulation?

Answer

Correct Answer: Wrapping functions and data into a single unit

Note: This Question is unanswered, help us to find answer for this one

550.

Which of the following illustrates correct synchronization syntax?

Answer

Correct Answer: public void Process(){ synchronized(this){ } }
public synchronized void Process(){}

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

551.

One method in your application needs to be synchronized. Which of the following options are correct for synchronization?

Answer

Correct Answer: public void Process(){ synchronized(this){ } }
public synchronized void Process(){}

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

552.

What would be the result of compiling and running the following code class?

 public class Test
{
 public static void main (String args[])
 {
 Test t = new Test ();
 t.start ();
 }
 public void start ()
 {
 int i = 2;
 int j = 3;
 int x = i & j;
 System.out.println (x);
 }
 }

Answer

Correct Answer: The code will compile and print 2

Note: This Question is unanswered, help us to find answer for this one

553.

Which of the following methods are members of the Vector class and allow you to input a new element?

Answer

Correct Answer: addElement

Note: This Question is unanswered, help us to find answer for this one

554.

Will the following code bind srvSock ?

 srvSock = new ServerSocket();

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

555.

For the given variables, which of the following will compile without an error?

char c = 'c';
int i = 50;
double d = 80;
long l = 200;
String s = "Goodbye";

Answer

Correct Answer: s+=i;

Note: This Question is unanswered, help us to find answer for this one

556.

What would happen on trying to compile and run the following code?

public class MainCls
{
     public static void main(String argv)
     {
 System.out.println("My Text");
     }
}

Answer

Correct Answer: The code will compile. A runtime error will occur because 'main' is not properly defined

Note: This Question is unanswered, help us to find answer for this one

557.

Inheritance is a process by which the objects of parent class acquire the properties of the child class.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

558.

Which class contains a method to create a directory?

Answer

Correct Answer: File

Note: This Question is unanswered, help us to find answer for this one

559.

What protocol is used by the DatagramSocket class?

Answer

Correct Answer: UDP

Note: This Question is unanswered, help us to find answer for this one

560.

What is wrong with the following code?

 class X extends Exception {}
 public class Y
 {
     public void foo()
     {
     try {
         b();
     }
     finally {
         ba();
     }
     catch (MyException e) {}
     }
 public void b() throws X {
 throw new X();
 }
 public void ba() throws RuntimeException {
 throw new RuntimeException();
 }
 }

Answer

Correct Answer: Finally block should come after the catch block

Note: This Question is unanswered, help us to find answer for this one

561.

All class methods in the java.lang package are thread safe. (in 1.5)

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

562.

Which of the following is a benefit derived from using OOPS?

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

563.

What will be written to the standard output when the following program is run?

public class X {
   public static void main(String args[]) {
    System.out.println(11 ^ 2);
   }
}

Answer

Correct Answer: 9

Note: This Question is unanswered, help us to find answer for this one

564.

Which of the following methods is used to get the parameters of an applet?

Answer

Correct Answer: getParameter()

Note: This Question is unanswered, help us to find answer for this one

565.

Are the following two statements equivalent?

 A: Thread.yield ();

 B: Thread.sleep (0);

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

566.

You want to loop through an array and stop when you come to the last element. Which of the following give information about the size of array, if its name is arMark?

Answer

Correct Answer: arMark.length;

Note: This Question is unanswered, help us to find answer for this one

567.

Can ServerSocket be used with UDP?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

568.

Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?

 class A {}
 class B extends A {}
 class C extends A {}
 public class X {
 public static void main(String args[]) {
 A x = new A();
 B y = new B();
 C z = new C();
 // insert statement here
 }
 }

Answer

Correct Answer: x = y;
y = (B)x;

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

569.

Which of the following is the correct syntax for suggesting that the JVM perform garbage collection?

Answer

Correct Answer: System.gc();

Note: This Question is unanswered, help us to find answer for this one

570.

What is the return type of the method ceil(double) from the Math class?

Answer

Correct Answer: double

Note: This Question is unanswered, help us to find answer for this one

571.

What is the java.net.IDN class in 1.6?

Answer

Correct Answer: Methods to convert internationalized domain names (IDNs) between a normal Unicode representation and an ASCII Compatible Encoding (ACE) representation

Note: This Question is unanswered, help us to find answer for this one

572.

What will be the output of the following code?

import java.util.*;
public class Test
{
public static void main (String args[]) throws Exception
{
List l = new ArrayList ();
int a = (int)(3 * 2.5);
for (int i = 0; i < 10; i++)
l.add (i);
String s = "Hello";
l.add (a, s.getBytes ("UTF-8")[2]);
System.out.println (l);
}
}

Answer

Correct Answer: [0, 1, 2, 3, 4, 5, 6, 108, 7, 8, 9]

Note: This Question is unanswered, help us to find answer for this one

573.

What will be the output of this program?

 public class Test
 {
 public static void main (String args[])
 {
 int a, b;
 a = 2;
 b = 0;
 System.out.println (g (a, new int[] {b}));
 }
 public static int g (int a, int b[])
 {
 b[0] = 2 * a;
 return b[0];
 }
 }

Answer

Correct Answer: 4

Note: This Question is unanswered, help us to find answer for this one

574.

Can the constructor of a class be made private?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

575.

What is true regarding the User Datagram Protocol (UDP)?

Answer

Correct Answer: A message is never partial
Messages are not guaranteed to arrive at destination

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

576.

is true regarding the socket API?

Answer

Correct Answer: None of them is true

Note: This Question is unanswered, help us to find answer for this one

577.

Is the following statement true or false?

 A .java file without any source code is a valid java file.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

578.

Which of the following statements is true of the HashMap class?

Answer

Correct Answer: It stores information as key/value pairs

Note: This Question is unanswered, help us to find answer for this one

579.

What should be the replacement of "//ABC" in the following code?

class Krit
{
    String str= new String("OOPS !!! JAVA");
    public void KritMethod(final int iArgs)
    {
      int iOne;
      class Bicycle
      {
        public void sayHello()
 {
          //ABC
        }
      }
    }
    public void Method2()
    {
      int iTwo;
    }
}

Answer

Correct Answer: System.out.print(str);
System.out.print(iArgs);

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

580.

What is the superclass of java.net.DatagramSocket?

Answer

Correct Answer: java.lang.Object

Note: This Question is unanswered, help us to find answer for this one

581.

Choose the correct statement:

Answer

Correct Answer: A call to a constructor in a parent class can only be made from within a constructor

Note: This Question is unanswered, help us to find answer for this one

582.

What will be the output of this program?

 public class Test
 {
 public static void main (String args[])
 {
 String a, b, c, d;
 a = ''Hello1234'';
 b = ''Hello'' + String.valueOf(1234);
 c = ''Hello'' + ''1234'';
 d = new String (new char[]{'H', 'e', 'l', 'l', 'o', '1', '2', '3', '4'});
 System.out.print (a == b);
 System.out.print ('' '');
System.out.print (a.equals(b));
 System.out.print ('' '');
 System.out.print (a == c);
 System.out.print ('' '');
System.out.print (a.equals(c));
 System.out.print ('' '');
 System.out.print (a == d);
 System.out.print ('' '');
System.out.print (a.equals(d));
 System.out.print ('' '');
 }
 }

Answer

Correct Answer: false true true true false true

Note: This Question is unanswered, help us to find answer for this one

583.

What will the length() method in the File class return?

Answer

Correct Answer: None of the above

Note: This Question is unanswered, help us to find answer for this one

584.

What will be the output of the following program?

 public class Test
 {
     public static void main (String args[ ])
     {
         B o = new A ();
         System.out.println (o.content ());
     }
     public String content () throws Exception
     {
         throw new Exception (''This is an exception on this.content ()'');
     }
     private static class B
     {
       public String content ()
         {
         return ''B'';
         }
      }
      private static class A extends B
 {
       public String content ()
         {
            return ''A'';
         }
      }
 }

Answer

Correct Answer: The code will compile and on running, it will print ''A''

Note: This Question is unanswered, help us to find answer for this one

585.

Is it possible to create an array of zero length?

Answer

Correct Answer: YES

Note: This Question is unanswered, help us to find answer for this one

586. You want to call a function written in C in your Java application remotely. How will you do it?


Answer

Correct Answer: Use CORBA

Note: This Question is unanswered, help us to find answer for this one

587. Maintaining object semantics means:


Answer

Correct Answer: Remote object appears same to the client machine as it does to the server machine

Note: This Question is unanswered, help us to find answer for this one

588. Read the following JSP code snippet and answer the question based upon it:

http://www.yourcompany.com/you TagLibrary /WEB-INF/yourTagLibrary.tld

From the statements given below, which one applies to the code snippet?

Answer

Correct Answer: The taglib directive can reference a TLD by name

Note: This Question is unanswered, help us to find answer for this one

589. which interface provides access to request scoped attributes?


Answer

Correct Answer: ServletRequest

Note: This Question is unanswered, help us to find answer for this one

590. You want to use transaction without connecting to a database every time a page is requested. Which of the following is a suitable solution?


Answer

Correct Answer: Create a single connection object in the init () method and implement SingleThreadModel

Note: This Question is unanswered, help us to find answer for this one

591. Which of the following interfaces allows a servlet to set the content length and MIME type, while replying to a client?


Answer

Correct Answer: ServletResponse Interface

Note: This Question is unanswered, help us to find answer for this one

592. What is output of the following program?

class student
{
     public : int marks;
    void disp()
    {
        cout<<"its base class"
    };
    class topper:public student
    {
        public :
        void disp()
        {
            cout<<"Its derived class";
        }
    }
    void main() { student s; topper t;
    s.disp();
    t.disp();
}


Answer

Correct Answer: Its base classIts derived class

Note: This Question is unanswered, help us to find answer for this one

593. Which of the following is true about the stub object?



Answer

Correct Answer: It can return a value or throw an exception

Note: This Question is unanswered, help us to find answer for this one

594. Where are victim hosts located with respect to a firewall?



Answer

Correct Answer: In the DMZ

Note: This Question is unanswered, help us to find answer for this one

595. Which of the following is the correct syntax for declaring a Remote Interface?


Answer

Correct Answer: public interface Remote { //empty }

Note: This Question is unanswered, help us to find answer for this one

596. What is the output of the following program?

class static_out
    {
        static int x;
     static int y;
        void add(int a , int b)
        {
            x = a + b;
            y = x + b;
        }
    }    
    class static_use
    {
        public static void main(String args[])
        {
            static_out obj1 = new static_out();
            static_out obj2 = new static_out();  
            int a = 2;
            obj1.add(a, a + 1);
            obj2.add(5, a);
            System.out.println(obj1.x + " " + obj2.y);    
        }
  }


Answer

Correct Answer: 7 9

Note: This Question is unanswered, help us to find answer for this one

597. X.509 version 3 specifies which of the following?


Answer

Correct Answer: A format and content for digital certificates

Note: This Question is unanswered, help us to find answer for this one

598. What is the output of the following program?

class overload
    {
        int x;
     int y;
        void add(int a)
        {
            x =  a + 1;
        }
        void add(int a, int b)
        {
            x =  a + 2;
        }        
    }    
    class Overload_methods
    {
        public static void main(String args[])
        {
            overload obj = new overload();  
            int a = 0;
            obj.add(6);
            System.out.println(obj.x);    
        }
  }


Answer

Correct Answer: 7

Note: This Question is unanswered, help us to find answer for this one

599. Which of the following is dummy reference for the client system?



Answer

Correct Answer: Stub object

Note: This Question is unanswered, help us to find answer for this one

600. What is the output of the given program?

import java.net. *;
class networking {
      public static void main(String[] args) throws UnknownHostException {
              InetAddress obj1 = InetAddress.getByName("cisco.com");
              System.out.print(obj1.getHostName());
                }
              }


Answer

Correct Answer: cisco.com

Note: This Question is unanswered, help us to find answer for this one

601. Which of the following is a Java API for managing enterprise services, systems and networks?


Answer

Correct Answer: JTA

Note: This Question is unanswered, help us to find answer for this one

602. Select the Correct Java Cryptography Architecture term for implementing security functions for the Java platform.

A.  It provides a platform and gives architecture and APIs for encryption and decryption.
B.  JCA is used by the developer to combine the application with the security measure.
C.  A programmer uses the JCA to meet the security measure.
D.  It helps in performing the third partly security rules.
E.  It uses the hash table, encryption message digest, etc. to implement the security.


Answer

Correct Answer: All the three of the above statements hold True.

Note: This Question is unanswered, help us to find answer for this one

603. Which of the following Java technologies support transaction processing?


Answer

Correct Answer: JTS

Note: This Question is unanswered, help us to find answer for this one

604. JDBC is based on:


Answer

Correct Answer: X/Open SQL Call Level Interface (CLI)

Note: This Question is unanswered, help us to find answer for this one

605. What is the output of the following program?

class string_class
    {
        public static void main(String args[])
        {
            String obj = "hello";
            String obj1 = "world";  
            String obj2 = obj;
            obj2 = " world";
            System.out.println(obj + " " + obj2);
        }
    }


Answer

Correct Answer: hello world

Note: This Question is unanswered, help us to find answer for this one

606. Which of the following is the name of the cookie used by Servlet Containers to maintain session information?



Answer

Correct Answer: JSESSIONID

Note: This Question is unanswered, help us to find answer for this one

607. Your boss has asked you to minimize object lookups by controlling the different locations of different objects across a distributed server. Which of the following servers will you use to complete the assignment?



Answer

Correct Answer: Centralized object server

Note: This Question is unanswered, help us to find answer for this one

608. What output will be sent to the browser by the following JSP code snippet?

   <!--
    Que <%="Reader"%>
   -->




Answer

Correct Answer: 'Que Reader' within HTML comment markers

Note: This Question is unanswered, help us to find answer for this one

609. RMI allows remote communication between:



Answer

Correct Answer: Java and Java

Note: This Question is unanswered, help us to find answer for this one

610. Choose True or False.

The class java.rmi.server.UnicastRemoteObject does NOT implement the java.lang.Cloneable interface.


Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

611. Applications can use one of two mechanisms to obtain references to remote objects. First is an application that can register its remote objects with RMI's simple naming facility, the rmiregistry. What is the second one?



Answer

Correct Answer: The application can pass and return remote object references as part of its normal operation

Note: This Question is unanswered, help us to find answer for this one

612. Which of the following is incorrect about the CallableStatement interface?


Answer

Correct Answer: CallableStatement cannot take IN OUT parameters 

Note: This Question is unanswered, help us to find answer for this one

613. How would you use a bean in a JSP page?



Answer

Correct Answer: jsp:useBean id="houseLotBean" scope="session" class="session.Realestate"/

Note: This Question is unanswered, help us to find answer for this one

614. What is the output of the given program?

import java.io.*;
        class streams
                { public static void main(String[] args) {
                        try {
                        FileOutputStream fos = new FileOutputStream("serial");
                        ObjectOutputStream oos = new ObjectOutputStream(fos);
                        oos.writeFloat(3.5);
                        oos.flush();
                        oos.close();
                }
                catch(Exception e) {
                        System.out.println("Serialization" + e);
                        System.exit(0);
                }
                try { FileInputStream fis = new FileInputStream("serial");
                ObjectInputStream ois = new ObjectInputStream(fis);
                ois.close();
                System.out.println(ois.available());
                }
                catch (Exception e) {
                        System.out.print("deserialization");                
                        System.exit(0);
                        }
            }
        }

        }


Answer

Correct Answer: 4

Note: This Question is unanswered, help us to find answer for this one

615. When a server wants to make an object available for URL lookups, it must bind that object instance to a string representing the:



Answer

Correct Answer: Object name

Note: This Question is unanswered, help us to find answer for this one

616. Choose the right syntax for a preparedStatement using ? as a placeholder for values namely CUSTOMER_ID,PRICE to be substituted while inserting values in the table ORDER:

PreparedStatement ps=con.prepareStatement("INSERT INTO ORDER (CUSTOMER_ID ,PRICE) VALUES(?,?)");


Answer

Correct Answer: ps.clearParameters(); <br>ps.setInt(1,3); ps.setDouble(2,790.50); ps.executeUpdate(); 

Note: This Question is unanswered, help us to find answer for this one

617. Which design pattern is used to decouple presentation from core data access functionality in JSP?



Answer

Correct Answer: Model-View-Controller

Note: This Question is unanswered, help us to find answer for this one

618. Which of the following is not required while you are developing a bean?



Answer

Correct Answer: Implementation of SingleThreadModel

Note: This Question is unanswered, help us to find answer for this one

619. Which of the following statements is/are correct about an rmic compiler?

1. It generates stub and skeleton class files using the Java Remote Method Protocol.
2. It generates stub and tie class files for remote objects by using the Internet Inter-Orb protocol (IIOP).


Answer

Correct Answer: Both statements 1 and 2 are correct.

Note: This Question is unanswered, help us to find answer for this one

620. Which of the following describes the Singleton pattern correctly?


Answer

Correct Answer: This pattern involves a single class which is responsible to create an object while making sure that the only single object gets created.

Note: This Question is unanswered, help us to find answer for this one

621. What are the authentication mechanisms used to secure web applications?

A.  Http Basic authentication
B.  Form-based authentication
C.  Digest authentication


Answer

Correct Answer: All the three of the above Statements hold True.

Note: This Question is unanswered, help us to find answer for this one

622. You want to access the database directly without using any additional software except Java. Which type of driver will you use?


Answer

Correct Answer: Native-Protocol /All-Java Driver

Note: This Question is unanswered, help us to find answer for this one

623. JDBC 2.0 API has the ability to create scrollable ResultSet. Which of the following will create the same?


Answer

Correct Answer: Statement st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); <br>ResultSet srs=st.executeQuery("SELECT CUS_NAME,PRICE FROM CUSTOMER");

Note: This Question is unanswered, help us to find answer for this one

624. Which of the following describes the Flyweight pattern correctly?


Answer

Correct Answer: This pattern hides the complexities of the system and provides an interface to the client using which the client can access the system.

Note: This Question is unanswered, help us to find answer for this one

625. Your project leader has asked you to extend the transaction across multiple page requests & multiple servlets. Which of the following will you use?



Answer

Correct Answer: Implement session tracking and use HttpSession object to hold onto connection for each user

Note: This Question is unanswered, help us to find answer for this one

626. What is the correct syntax of object binding to URL?


Answer

Correct Answer: java.rmi.Naming.rebind ("name", object);

Note: This Question is unanswered, help us to find answer for this one

627. You have made a small change to one of your classes. It compiles and RMIC works, but the application shows an error when run. What is the solution?


Answer

Correct Answer: Shut down and restart rmiregistry

Note: This Question is unanswered, help us to find answer for this one

628. Which of the following is true about rmic?


Answer

Correct Answer: It is a hybrid of java and javac commands

Note: This Question is unanswered, help us to find answer for this one

629. The doGet method is used to handle GET, conditional GET and HEAD requests. By default, which of the following error numbers is returned by this method?


Answer

Correct Answer: 400

Note: This Question is unanswered, help us to find answer for this one

630. In which directory do you place servlet class files?


Answer

Correct Answer: WEB-INF\classes

Note: This Question is unanswered, help us to find answer for this one

631. Imagine you are given 10,000 files, each containing 1 Million integers. Below is the Code which wil sum all of them and give the final result. Will the below mentioned code compiles and throws output?
public getSum(String[] file_names) {
    int sum = 0;
   for(String f: file_names) {
    sum = sum + sumOfFile(f);
   }
  return sum;
}


Answer

Correct Answer: NO

Note: This Question is unanswered, help us to find answer for this one

632. How can you make callbacks if the client is behind the firewall?


Answer

Correct Answer: It is not possible

Note: This Question is unanswered, help us to find answer for this one

633. Select the correct statement which defines that the Purpose of load balancing is to:

A.  optimize the resource usage(Avoid overload and under-load of any machines).
B.  achieve the maximum throughput.
C.  minimize response time.


Answer

Correct Answer: All the three of the above Statements hold True.

Note: This Question is unanswered, help us to find answer for this one

634. A remote object makes itself available to the world using:



Answer

Correct Answer: java.rmi.server.UnicastRemoteObject

Note: This Question is unanswered, help us to find answer for this one

635. Suppose you had a servlet that simply returned an error message because that resource was forbidden to that user. Read the following code snippet:

1. public void service(HttpServletRequestrequest,
2.           HttpServletResponseresponse)
3. throws ServletException, IOException
4. {
5.
6. }

What code would you type on line 5 to return an error message to the requesting client?



Answer

Correct Answer: response.sendError(HTTPServletResponse.SC_FORBIDDEN,"Error");

Note: This Question is unanswered, help us to find answer for this one

636. In case of remote method call, remote objects are passed by:



Answer

Correct Answer: Reference

Note: This Question is unanswered, help us to find answer for this one

637. Which of the following is the correct syntax of init() method in Servlet Interface?



Answer

Correct Answer: public abstract void init(ServletConfig cof) throws ServletException

Note: This Question is unanswered, help us to find answer for this one

638. You want to send transient data after serializing it. How will you do it?



Answer

Correct Answer: It is not possible

Note: This Question is unanswered, help us to find answer for this one

639. What will you do to flag an object as a remote object?



Answer

Correct Answer: Implement an interface that extends java.rmi.Remote interface

Note: This Question is unanswered, help us to find answer for this one

640. Which of the following statements is correct about declaration of a remote interface, RemoteTrain?


Answer

Correct Answer: public interface RemoteTrain extends java.rmi.Remote

Note: This Question is unanswered, help us to find answer for this one

641. Which of the following JDBC methods is used to retrieve BLOB data?


Answer

Correct Answer: getBinaryStream()

Note: This Question is unanswered, help us to find answer for this one

642. Select the Correct security features and APIs provided in Java SE?

A.  Java Authentication and Authorization Service (JAAS)
B.  Java Generic Security Services (JGSS)
C.  Java Cryptography Extension (JCE)
D.  Java Secure Sockets Extension (JSSE)
E.  Simple Authentication and Security Layer (SASL)


Answer

Correct Answer: All the three of the above Statements hold True.

Note: This Question is unanswered, help us to find answer for this one

643. The Java RMI registry, by default, runs on TCP port 1099. Which of the following is the correct command to start the RMI registry on a different port such as 2005?


Answer

Correct Answer: start rmiregistry 2005

Note: This Question is unanswered, help us to find answer for this one

644. Which method is called by the servlet container just after the servlet is removed from service?



Answer

Correct Answer: public void destroy() {// code...}

Note: This Question is unanswered, help us to find answer for this one

645. Which of the following is/are contained in a Java security policy file?


Answer

Correct Answer: Granted entries

Note: This Question is unanswered, help us to find answer for this one

646. Which of the following is true about a remote object?


Answer

Correct Answer: Stub object perform networking routine

Note: This Question is unanswered, help us to find answer for this one

647. Find the output of the following program:

class education
{
    char name[10];
    public : disp()
    {
        cout<<"Its education system";
    }
    class school:public education
    {
        public: void dsip()
        {
            cout<<"Its school education system";
        }
    };
    void main()
    {
                school s;
                s.disp();
    }
}


Answer

Correct Answer: Its school education system

Note: This Question is unanswered, help us to find answer for this one

648. Which among the following would destroy the encapsulation mechanism if it was allowed in the programming?


Answer

Correct Answer: Using access declaration for the private members of base class.

Note: This Question is unanswered, help us to find answer for this one

649. Which of the following describes the Filter pattern correctly?


Answer

Correct Answer: This pattern refers to creating a duplicate object while keeping the performance in mind.

Note: This Question is unanswered, help us to find answer for this one

650. Which of the following occurs first in the object oriented development cycle?


Answer

Correct Answer: Problem statement

Note: This Question is unanswered, help us to find answer for this one

651. Choose the correct statement.

A.  Scaling Up
This involves adding more resources to the existing nodes. For example, adding more RAM, Storage or processing power.

B.  Scaling Out
This involves adding more nodes to support more users.


Answer

Correct Answer: Both the above Statements hold True.

Note: This Question is unanswered, help us to find answer for this one

652. What is the output of the following code?

class San
{
 public void m1 (int i,float f)
{
  System.out.println(" int float method");
}

 public void m1(float f,int i);
  {
  System.out.println("float int method");
  }

  public static void main(String[]args)
  {
    San s=new San();
        s.m1(20,20);
  }
}


Answer

Correct Answer: compile time error

Note: This Question is unanswered, help us to find answer for this one

653. Which of the following options is a valid JSP expression?


Answer

Correct Answer: %=(new java.util.Date()).toLocaleString() %

Note: This Question is unanswered, help us to find answer for this one

654. What is the output of the given program?

import java.net.*;

    class networking {
        public static void main(String[] args) throws UnknownHostException {

            InetAddress obj1 = InetAddress.getByName("cisco.com");
            InetAddress obj2 = InetAddress.getByName("inputoutput.com");
            boolean x = obj1.equals(obj2);
            System.out.print(x);
        }
    }


Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

655. Which design pattern did technical designers of JSP use to provide centralized dispatching of requests via a controller servlet?



Answer

Correct Answer: Model-view-Controller

Note: This Question is unanswered, help us to find answer for this one

656. To load a servlet repeatedly, which of the following objects will be used?



Answer

Correct Answer: custom ClassLoader object

Note: This Question is unanswered, help us to find answer for this one

657. Which of the following connection methods is/are provided by JDBC to create statements with a desired ResultSet?


Answer

Correct Answer: createStatement(int RSType, int RSConcurrency);

Note: This Question is unanswered, help us to find answer for this one

658. Which of the following terms supports object reuse?


Answer

Correct Answer: Class Inheritance

Note: This Question is unanswered, help us to find answer for this one

659. Which statement is correct about ServletContextListner?


Answer

Correct Answer: An object that implements a context listener is notified when its Web App context is created or destroyed

Note: This Question is unanswered, help us to find answer for this one

660. Callbacks have two main limitations. The first is that only that server to which the client has already connected can call methods in a remote client object. The second is:



Answer

Correct Answer: Object servers can get remote object references only as method parameters or return values

Note: This Question is unanswered, help us to find answer for this one

661. Clustering is used in many types of servers for high availability. Select the correct statement definition used in Clustering.

A.  App Server Cluster
An app server cluster is a group of machines that can run an application server that can be reliably utilized with a minimum of down-time.
B.  Database Server Cluster
An database server cluster is a group of machines that can run a database server that can be reliably utilized with a minimum of down-time.


Answer

Correct Answer: Both the above Statements holds True.

Note: This Question is unanswered, help us to find answer for this one

662. Which of the following statements are true regarding the structure of a Web Archive file?



Answer

Correct Answer: It is a JAR archive of the WebApplication structure

Note: This Question is unanswered, help us to find answer for this one

663. Servlet developers should avoid using JDBC-ODBC bridge driver because:


Answer

Correct Answer: Driver's native code can crash the entire server

Note: This Question is unanswered, help us to find answer for this one

664. How many instances of String Object are created in the following line of code? String a = "b" + "c"

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

665. public void myMethod(String... strings){ // method body } Which call of myMethod() is not correct?

Answer

Correct Answer: myMethod({"a", "b", "c"});

Note: This Question is unanswered, help us to find answer for this one

666. It is useful to have a private constructor in a java object ?

Answer

Correct Answer: Used to construct a singleton

Note: This Question is unanswered, help us to find answer for this one

667. Which of these operators is used to allocate memory for an object?

Answer

Correct Answer: new

Note: This Question is unanswered, help us to find answer for this one

668. You have the following method, which throws an unchecked exception public boolean testArg(Integer n) throws IllegalArgumentException { if (n == null) throw new IllegalArgumentException(); /* ... */ } Is this throw specification correct?

Answer

Correct Answer: Yes. You need not specify an unchecked exception, but you are allowed to do so.

Note: This Question is unanswered, help us to find answer for this one

669. Which of these statements is TRUE for enums:

Answer

Correct Answer: Enum can implement an interface.

Note: This Question is unanswered, help us to find answer for this one

670. public @interface A { String value(); } How would you change the "value" element declaration to give it an empty String as its default?

Answer

Correct Answer: String value() default "";

Note: This Question is unanswered, help us to find answer for this one

671. The default constructor of an enum type is implicitly:

Answer

Correct Answer: private

Note: This Question is unanswered, help us to find answer for this one

672. Add this annotation to your annotation declaration in order to ensure it's available for reflection.

Answer

Correct Answer: @Retention(RetentionPolicy.RUNTIME)

Note: This Question is unanswered, help us to find answer for this one

673. Hibernate code: @Entity public class Foo{ String key; @Id public String getId() { return id; } public void setId(String id) { this.id = id; } } In the above code, Will be executed successfully?

Answer

Correct Answer: No, there is an error in hibernate and generates an exception

Note: This Question is unanswered, help us to find answer for this one

674. byte a = 64; byte b = (byte) (a << 2); What is the value of b?

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

675. Output of Program byte i; for(i=0;i<128;i++) System.out.print(i);

Answer

Correct Answer: Infinite loop

Note: This Question is unanswered, help us to find answer for this one

676. Of the following, which is not a java.lang Class?

Answer

Correct Answer: Arrays

Note: This Question is unanswered, help us to find answer for this one

677. What will be the output of following Java code: int someVariable = 10_000; int someAnotherVar = 10000; if(someVariable == 10000){ System.out.println("equal"); } else{ System.out.println("not equal"); }

Answer

Correct Answer: Runs successfully and prints

Note: This Question is unanswered, help us to find answer for this one

678. such construct in Java: class Foo { { // some code } }

Answer

Correct Answer: is an instance initializer, additional to constructor and called before it

Note: This Question is unanswered, help us to find answer for this one

679. When using swing, which of the following is NOT a method on a JCheckBox object?

Answer

Correct Answer: checkb.addListener(Listener);

Note: This Question is unanswered, help us to find answer for this one

680. Java is a pure object oriented language. true or false?

Answer

Correct Answer: false

Note: This Question is unanswered, help us to find answer for this one

681. public class SomeClass { public static void main(String[] args) { System.out.println(null); } } Does this code compile without errors?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

682. By which method does Java pass data?

Answer

Correct Answer: Pass by value only.

Note: This Question is unanswered, help us to find answer for this one

683. What is the difference between an inner class and a nested class?

Answer

Correct Answer: A nested class is any class that is defined within another class. An inner class is a non-static nested class.

Note: This Question is unanswered, help us to find answer for this one

684. In Java, "const" is:

Answer

Correct Answer: a reserved but unused keyword

Note: This Question is unanswered, help us to find answer for this one

685. Can a constructor be final?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

686. Is it possible to start a thread twice?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

687. What's the worst-case complexity of the function Arrays.sort(int[])?

Answer

Correct Answer: O(n^2)

Note: This Question is unanswered, help us to find answer for this one

688. How many bytes are in a long in Java?

Answer

Correct Answer: 8

Note: This Question is unanswered, help us to find answer for this one

689. Can you overload a static method signature?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

690. A nested class declared inside a block (a local class) can access other variables defined in its immediately enclosing scope, but only when they are:

Answer

Correct Answer: final

Note: This Question is unanswered, help us to find answer for this one

691. Which of the following statements are true?

Answer

Correct Answer: (-1 >>> 1) == Integer.MAX_VALUE

Note: This Question is unanswered, help us to find answer for this one

692. A subclass's constructor will always implicitly call its superclass's default, no-argument constructor except when:

Answer

Correct Answer: The subclass constructor in question makes an explicit call to another of its superclass's constructors.

Note: This Question is unanswered, help us to find answer for this one

693. Java annotations. Which is not a predefined annotation type?

Answer

Correct Answer: @Overload

Note: This Question is unanswered, help us to find answer for this one

694. A java.util.ConcurrentModificationException can be thrown in a mono-threaded application.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

695. True or false? StringBuilder is Thread-safe.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

696. During execution of code inside a "synchronized" statement, threads other than the executing one are prevented from:

Answer

Correct Answer: Acquiring the built-in lock associated with the object referenced by the synchronized statement

Note: This Question is unanswered, help us to find answer for this one

697. package P; public class A { int m; }; Who has access to member `m'?

Answer

Correct Answer: class A, classes from package P

Note: This Question is unanswered, help us to find answer for this one

698. If x is a byte and y is a double, what is an acceptable type for variable z in this expression? z = (short) x/y * 2;

Answer

Correct Answer: Double

Note: This Question is unanswered, help us to find answer for this one

699. What is the result when you compile and run the following code? public class Test { public void method() { for(int i = 0; i < 3; i++) { System.out.print(i); } System.out.print(i); } }

Answer

Correct Answer: Compilation error

Note: This Question is unanswered, help us to find answer for this one

700. boolean b = 1 > 0 ? 1 < 0 : false; What is the value of b?

Answer

Correct Answer: false

Note: This Question is unanswered, help us to find answer for this one

701. Which one of the following statements is false?

Answer

Correct Answer: An abstract class cannot implement an interface.

Note: This Question is unanswered, help us to find answer for this one

702. What is the difference between static inner class and a non static inner class?

Answer

Correct Answer: A static inner class has no reference to its parent class, a non static inner class does.

Note: This Question is unanswered, help us to find answer for this one

703. What are the minimum and maximum values of a byte?

Answer

Correct Answer: -128 and 127

Note: This Question is unanswered, help us to find answer for this one

704. Which of the following APIs is used to create secure socket connections and manage digital certificates?

Answer

Correct Answer: JSSE

Note: This Question is unanswered, help us to find answer for this one

705. What is one of the benefits of Generics in Java?

Answer

Correct Answer: Elimination of Casts when getting objects from Collections

Note: This Question is unanswered, help us to find answer for this one

706. Which of the following is true about this Java snippet: String a = "hello"; String b = "hello"; boolean x = (a == b);

Answer

Correct Answer: x can be true because of Java String interning.

Note: This Question is unanswered, help us to find answer for this one

707. The keyword 'volatile' on a field is used in Java to:

Answer

Correct Answer: Guarantee that the field's current value is read, not a thread-cached value.

Note: This Question is unanswered, help us to find answer for this one

708. Which of the following variable declarations is illegal in Java?

Answer

Correct Answer: List myVar;

Note: This Question is unanswered, help us to find answer for this one

709. An Enum implicitly implements which interface?

Answer

Correct Answer: Comparable and Serializable

Note: This Question is unanswered, help us to find answer for this one

710. Which of the following can be abstract?

Answer

Correct Answer: None of these

Note: This Question is unanswered, help us to find answer for this one

711. How do you define your own annotation type?

Answer

Correct Answer: @interface MyAnnotation { /* ... */ }

Note: This Question is unanswered, help us to find answer for this one

712. Which of these statements is correct?

Answer

Correct Answer: return, goto and default are keywords in the Java language

Note: This Question is unanswered, help us to find answer for this one

713. Which of the following IS NOT a property of the equals() method?

Answer

Correct Answer: atomic

Note: This Question is unanswered, help us to find answer for this one

714. which of the following can cause serious system failures??

Answer

Correct Answer: suspend()

Note: This Question is unanswered, help us to find answer for this one

715. Which of the following *classes* include the getSession method used to retrieve an object that implements the HttpSession interface?

Answer

Correct Answer: HttpServletRequest

Note: This Question is unanswered, help us to find answer for this one

716. When is an object's finalize method called?

Answer

Correct Answer: Whenever the JVM's garbage collection algorithm decides to call it.

Note: This Question is unanswered, help us to find answer for this one

717. Which JVM parameter is used to set the maximum heap memory size?

Answer

Correct Answer: Xmx

Note: This Question is unanswered, help us to find answer for this one

718. Can a HashMap contain a null key?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

719. Which of the following is false regarding a class of a JavaBeans component?

Answer

Correct Answer: it is transient

Note: This Question is unanswered, help us to find answer for this one

720. Does Java provide any construct to find out the size of an object?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

721. If I write System.exit (0); at the end of the try block, will the finally block still execute?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

722. What is the default scope of a method?

Answer

Correct Answer: package-private

Note: This Question is unanswered, help us to find answer for this one

723. A call to System.gc() does what?

Answer

Correct Answer: Suggests that the JVM run garbage collection to reclaim memory.

Note: This Question is unanswered, help us to find answer for this one

724. The Java Virtual Machine manages its own:

Answer

Correct Answer: memory and allocates it as necessary.

Note: This Question is unanswered, help us to find answer for this one

725. find the correct output: StringBuffer fb= new StringBuffer("one two one"); int i, j ; i= fb.indexOf("one"); System.out.println(i); j= fb.LastIndexOf("one"); System.out.println(j);

Answer

Correct Answer: 0, 8

Note: This Question is unanswered, help us to find answer for this one

726. What does a synchronized method use as a mutex in Java?

Answer

Correct Answer: The owning object's (this's) mutex.

Note: This Question is unanswered, help us to find answer for this one

727. Are static fields of a class included in serialization?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

728. public class SomeClass { public static void main(String[] args) { System.out.println(((String)null).toUpperCase()); } } What is the result of the following program?

Answer

Correct Answer: The code throws NullPointerException.

Note: This Question is unanswered, help us to find answer for this one

729. Non-static attributes can be accessed without an instance of the class.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

730. public class SomeClass { public static void main(String[] args) { System.out.println((String)null); } } What is the result of the following program?

Answer

Correct Answer: The code prints "null" on console.

Note: This Question is unanswered, help us to find answer for this one

731. what are the parts of JNDI architecture

Answer

Correct Answer: JNDI API and JNDI SPI

Note: This Question is unanswered, help us to find answer for this one

732. Which of these is the wildcard symbol for use in generic type specification?

Answer

Correct Answer: ?

Note: This Question is unanswered, help us to find answer for this one

733. Is "main" a keyword in Java?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

734. SWING Toolkit contains

Answer

Correct Answer: component set (subclasses of JComponent),support classes,interfaces

Note: This Question is unanswered, help us to find answer for this one

735. Java interfaces can extend...

Answer

Correct Answer: multiple interfaces.

Note: This Question is unanswered, help us to find answer for this one

736. What is the keyword to forbid the serialization of an instance field?

Answer

Correct Answer: transient

Note: This Question is unanswered, help us to find answer for this one

737. Which method is used to sort a Collection by natural order of its elements?

Answer

Correct Answer: Collections.sort

Note: This Question is unanswered, help us to find answer for this one

738. In Math and other java.lang Classes, generally all methods are declared _.

Answer

Correct Answer: static

Note: This Question is unanswered, help us to find answer for this one

739. What is an abstract class?

Answer

Correct Answer: A class that does not define all of its methods

Note: This Question is unanswered, help us to find answer for this one

740. Any source code valid for one version of Java is also valid for all previous versions of Java.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

741. Consider the following code: int i=aReader.read(); What is the true of the type of variable aReader?

Answer

Correct Answer: It can either be a FileReader or a BufferReader.

Note: This Question is unanswered, help us to find answer for this one

742. Which of these keywords is used to manually clean up memory in java?

Answer

Correct Answer: finalize

Note: This Question is unanswered, help us to find answer for this one

743. String objects in Java are immutable which means:

Answer

Correct Answer: that, if constant, they cannot be changed once they are created.

Note: This Question is unanswered, help us to find answer for this one

744. If you override method "equals()", what other function you must override for the class to work properly?

Answer

Correct Answer: public int hashCode()

Note: This Question is unanswered, help us to find answer for this one

745. If you set one object variable equal to another object variable:

Answer

Correct Answer: you end up with one copy of the data and two references to the data.

Note: This Question is unanswered, help us to find answer for this one

746. Java programs must have at least one method called main() _____.

Answer

Correct Answer: In order to execute

Note: This Question is unanswered, help us to find answer for this one

747. The foreach loop in Java is constructed as:

Answer

Correct Answer: for (Object o : collection)

Note: This Question is unanswered, help us to find answer for this one

748. Java's Reflection feature allows you to do things including (but not limited to) :

Answer

Correct Answer: Obtain the names of a class' members and display them at runtime.

Note: This Question is unanswered, help us to find answer for this one

749. Can a non-generic class have a generic constructor?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

750. If "A" is a class, then what does the statement "A a1;" do?

Answer

Correct Answer: The object reference variable 'a1' is declared.

Note: This Question is unanswered, help us to find answer for this one

751. The "synchronized" keyword does the following

Answer

Correct Answer: Prevents concurrency within methods or statements

Note: This Question is unanswered, help us to find answer for this one

752. What is the command to run an executable JAR file named program.jar?

Answer

Correct Answer: java -jar program.jar

Note: This Question is unanswered, help us to find answer for this one

753. Which of the following is *not* a method in java.lang.String?

Answer

Correct Answer: boolean isNull()

Note: This Question is unanswered, help us to find answer for this one

754. Any valid program compiled under one version of Java...

Answer

Correct Answer: ...will generally run under future versions of the platform.

Note: This Question is unanswered, help us to find answer for this one

755. Can you mark an interface as final?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

756. TreeMap class is used to implement which collection interface?

Answer

Correct Answer: SortedMap

Note: This Question is unanswered, help us to find answer for this one

757. Which Map implementation is safe for modification in a multi-threaded program?

Answer

Correct Answer: java.util.concurrent.ConcurrentHashMap

Note: This Question is unanswered, help us to find answer for this one

758. Can a class be both abstract and final?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

759. output of program class Test {T obj; Test(T obj) { this.obj=obj } T getobj() {return obj; } } class RunC {public static void main(String[] ar) { Test obj=new Test("hello"); System.out.print(obj.getobj()); } }

Answer

Correct Answer: hello

Note: This Question is unanswered, help us to find answer for this one

760. Java allows you to specify two types of variables: primitive, which store a single value, and

Answer

Correct Answer: reference, where the data is accessed indirectly.

Note: This Question is unanswered, help us to find answer for this one

761. Can we override a static method?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

762. A method is considered to be overloaded when:

Answer

Correct Answer: they have multiple call signatures

Note: This Question is unanswered, help us to find answer for this one

763. What is displayed when the following code is compiled and executed? String s1 = new String("Test"); String s2 = new String("Test"); if (s1==s2) System.out.println("Same"); if (s1.equals(s2)) System.out.println("Equals");

Answer

Correct Answer: Equals

Note: This Question is unanswered, help us to find answer for this one

764. ________ is when a subclass implements a method that is already provided by a superclass.

Answer

Correct Answer: Method overriding

Note: This Question is unanswered, help us to find answer for this one

765. Can you declare an abstract class with no abstract methods?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

766. How do you prevent a class from being extended by a subclass?

Answer

Correct Answer: Declare the class as final.

Note: This Question is unanswered, help us to find answer for this one

767. Under the strictest definition, an interface may contain only:

Answer

Correct Answer: abstract methods

Note: This Question is unanswered, help us to find answer for this one

768. If I write return at the end of the try block, will the finally block still execute?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

769. What effect does declaring a method as final have?

Answer

Correct Answer: The method cannot be overridden in subclasses.

Note: This Question is unanswered, help us to find answer for this one

770. What company developed java?

Answer

Correct Answer: Sun Microsystems (Oracle)

Note: This Question is unanswered, help us to find answer for this one

771. Which of the following is correct for the "main" method of a class?

Answer

Correct Answer: public static void main(String [] args) { }

Note: This Question is unanswered, help us to find answer for this one

772. What keyword is used to add external package members to the current Java file?

Answer

Correct Answer: import

Note: This Question is unanswered, help us to find answer for this one

773. As a general syntax rule, Java is case sensitive on:

Answer

Correct Answer: all platforms.

Note: This Question is unanswered, help us to find answer for this one

774. You can use the 'static' keyword for which of the following?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

775. An applet can do which of the following?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

776. Class definitions in Java can have which of the following access levels?

Answer

Correct Answer: all of these

Note: This Question is unanswered, help us to find answer for this one

777. All Java files must have a .java extension and are compiled with the:

Answer

Correct Answer: javac compiler

Note: This Question is unanswered, help us to find answer for this one

778. Which of the following is the correct signature for a main method that can be used as an entry point by the Java runtime?

Answer

Correct Answer: public static void main(String[] args)

Note: This Question is unanswered, help us to find answer for this one

779. public class Dog extends Animal{ ... } is an example of...

Answer

Correct Answer: Inheritance

Note: This Question is unanswered, help us to find answer for this one

780. The varargs method: public void foo(String... strings) may be called with:

Answer

Correct Answer: All of these.

Note: This Question is unanswered, help us to find answer for this one

781. The process of changing a datatype of a value is called:

Answer

Correct Answer: typecasting

Note: This Question is unanswered, help us to find answer for this one

782. Which keywords would you use to handle exceptions in Java?

Answer

Correct Answer: try, catch, finally

Note: This Question is unanswered, help us to find answer for this one

783. The correct operator for 'conditional or' is:

Answer

Correct Answer: ||

Note: This Question is unanswered, help us to find answer for this one

784. _____ jumps out of an entire loop, whereas _____ jumps to the next iteration.

Answer

Correct Answer: break; continue

Note: This Question is unanswered, help us to find answer for this one

785. When you run a Java program, the system is running the Java Runtime Engine (JRE) as an executable which then:

Answer

Correct Answer: processes the java code through the Java Virtual Machine (JVM).

Note: This Question is unanswered, help us to find answer for this one

786. What are the core JMS-related objects required for each JMS-enabled application?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

787. Do you need to explicitly define a constructor for every class?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

788. Which of these keywords is used to define packages in Java?

Answer

Correct Answer: package

Note: This Question is unanswered, help us to find answer for this one

789. What is the proper syntax for a Java class's main method?

Answer

Correct Answer: public static void main(String[] args)

Note: This Question is unanswered, help us to find answer for this one

790. What is the syntax for creating a class derived from the class named MyClass?

Answer

Correct Answer: class MyDerived extends MyClass

Note: This Question is unanswered, help us to find answer for this one

791. A JavaBean is a special Java class:

Answer

Correct Answer: all of these

Note: This Question is unanswered, help us to find answer for this one

792. Will a program run if the main() is not static?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

793. Can an interface have member variables?

Answer

Correct Answer: Yes, as long as they are public, static and final

Note: This Question is unanswered, help us to find answer for this one

794. Which of the following JNDI properties provide security information?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

795. The pattern described below is known as: public class Foo{ private static Foo instance; private Foo(){ } private static getInstance(){ if (instance == null){ instance = new Foo(); } return instance; }

Answer

Correct Answer: the Singleton pattern

Note: This Question is unanswered, help us to find answer for this one

796. Are primitive data types passed by reference or passed by value?

Answer

Correct Answer: Passed by value

Note: This Question is unanswered, help us to find answer for this one

797. Which statement is wrong?

Answer

Correct Answer: ArrayList<String> myList = new ArrayList<Integer>();

Note: This Question is unanswered, help us to find answer for this one

798. What's wrong with the following method: public static int getSize(){ int temp = super.getSize(); if(temp==0) temp=this.size; return temp; }

Answer

Correct Answer: static methods cannot refer to "this" or "super"

Note: This Question is unanswered, help us to find answer for this one

799. You read the following statement in a valid Java program: submarine.dive(depth); What must be true?

Answer

Correct Answer: "dive" must be a method.

Note: This Question is unanswered, help us to find answer for this one

800. Can static and abstract keywords be used together?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

801. public class A { private int m = 5; class N { private int m = 3; public void print() { System.out.println("m=" + m); } } public static void main(String[] args) { A a = new A(); N n = a.new N(); n.print(); } } What is the output?

Answer

Correct Answer: m=3

Note: This Question is unanswered, help us to find answer for this one

802. What will be the output of below code String a="abc"; String b="abc"; String c=new String("abc"); if(a==c && a.equals(b)){ System.out.println("They are equal"); } else System.out.println("They are not equal");

Answer

Correct Answer: They are not equal

Note: This Question is unanswered, help us to find answer for this one

803. The StringBuffer and StringBuilder classes in Java are optimized for

Answer

Correct Answer: creating strings which change considerably.

Note: This Question is unanswered, help us to find answer for this one

804. The @Override annotation

Answer

Correct Answer: All of these answers are correct

Note: This Question is unanswered, help us to find answer for this one

805. Which of the following is true for interface variables.

Answer

Correct Answer: They may exist, but they must be public, static and final.

Note: This Question is unanswered, help us to find answer for this one

806. Which method is used to force one thread to wait for another thread to finish?

Answer

Correct Answer: join()

Note: This Question is unanswered, help us to find answer for this one

807. Which java class provides variables local to each thread?

Answer

Correct Answer: ThreadLocal

Note: This Question is unanswered, help us to find answer for this one

808. If you need to determine exactly which class your object is:

Answer

Correct Answer: use the getClass() method.

Note: This Question is unanswered, help us to find answer for this one

809. How do we compare enum types in java

Answer

Correct Answer: Both

Note: This Question is unanswered, help us to find answer for this one

810. How many objects are created: String s1="String"; String s2="String"; String s3="String";

Answer

Correct Answer: One

Note: This Question is unanswered, help us to find answer for this one

811. Will a program compile if the main method is defined private?

Answer

Correct Answer: Yes, but will not run

Note: This Question is unanswered, help us to find answer for this one

812. A function that defines the steps necessary to instantiate one object of that class is called:

Answer

Correct Answer: a constructor.

Note: This Question is unanswered, help us to find answer for this one