500 MCQ's - Answers
500 MCQ's - Answers
1. _________ are tokens that convey a special meaning to the java compiler. (a. operators b. keywords c. constants d.
identifiers)
2. _________ are characters which define the structure of a program. (a. punctuators b. keywords c. literals d. operators
)
3. The default value of boolean datatype is __________. ( a. true b. false c. null d. 0)
4. char data type occupies ______ bits of memory (a. 16 b. 2 c. 8 d. 32)
5. _______ are remarks written by the programmer and are ignored by the compiler. (a. escape sequence b. comments
c. constants d. identifiers)
6. The precision of float values is ____________ (a. 7 b. 15 c. 9 d. 8)
7. The Unicode equivalent of a null character is ______.( a. “” b. /U0000 c. \U0000 d. \U000)
8. By default java treats real numbers as _______. (a. byte b. float c. double d. int )
9. Relational operators return _______ datatype (a. char b. String c. boolean d. double)
10. double +float = _________ datatype (a. double b. float c. long d. int)
11.Relational operators join two or more expressions in disjunction.( a. true b. false )
12.Intrinsic simple datatypes are called as primitive datatypes( a. true b. false)
13.The default value of char is '\U0000' (a. true b. false)
14.true and false are java keywords (a. true b. false)
15.Coercion is conversion done explicitly by type casting operators.( a. true b. false)
16. += is an unary operator (a. true b. false)
17. ‘\n’ is a valid character literal a. true b. false
18. The maximum length of a java identifier can be 255.(a. true b. false)
19. Constants can be changed only once during execution of the program.(a. true b. false)
20. -127 is the smallest value that can stored in a byte datatype( a. true b. false)
21. Determines execution of operators when more than one operator of the same precedence appears in an expression.
(a. operator precedence b. operator associativity c. operands d.operator assignment)
22. Operators which require only one operand to complete an expression(a. binary b. uniform c. unary d.ternary)
23. Expressions which contain the same type of operands.( a. pure b. impure c. mixed,real)
24. Escape sequence used to print a new line (a. \l b. \n c. \t d.\r)
25. Set of Characters enclosed in “ “.(a. int b. char c. String d.float)
26. Given m = 3, n = 4; the value of ans is: ans = --m + --n + m-- - --n; (a. 6 b. 5 c. 7 d. 4 )
27. Given int k=5,j=9; k= k++ - ++k - ++j - j++ +k; System.out.println(k+" "+j);(a.-16 10 b.-13 13 c.-14 12 d.-15 11)
28. Given a=10 , b=12 a *= a++ - b-- + ++a - ++b;( a. -21 b. -18 c. -20 d. -19 )
29. Given a=5,b=6,c=7; a %= a++ * ++b / c++ + ++c; (a. 3 b. 4 c. 5 d. 6)
30. Given int x=4, y=7 ,z=10; System.out.println(x-y<z && y+z>x || x-z<=y-x+z); (a. true b. false c. 4 d. 10)
31. The output of the following will be: System.out.print("one"+"ten"+1+10); System.out.print("one"+"ten"+(1+10)); (a.
oneten11 oneten(1+10) b. oneten110 oneten11 c. oneten110 onten110 d. oneten11 11oneten)
32. Arrange the following in the correct order of precedence (higher to lower) +, /, &&, ==, --, += (a. +=, &&, ==, +, /, -- b.
--, +, /, ==, &&, += c. --, /, +, ==, &&, += d. --, /, +, &&, ==, += )
33. Which is the most appropriate ternary operator to print the value of the biggest number out of 2 numbers( a.
System.out.println( a>b ? b : a); b. System.out.println(a > b : a ? b); c. System.out.println(a>b? a : b); d.
System.out.println(a>b ? "a" : "b" );)
34. The number of bits occupied by the following data types are : short, float (a. 2,4 b. 16,32 c. 8,64 d. 16,24)
35. The keyword which prevents fall through is ____________. (a. default b. break c. case d. continue)
36. ? : is an example of ___________ operator (a. iterative b. binary c. unary d. conditional)
37. The _______ statements unconditionally transfer program control.( a. conditional b. interative c. jump d. decision
making )
38. __________ loop executes at least once even if the condition is false.( a. for b. while c. do-while d. none)
39. The ______ statement skips the current pass of a loop’s body (a. break b. return c. continue d. System.exit(0))
40.The first line of the function definition is known as _________.( a. function signature. b. constructor. c. function
prototype. d. function parameters.)
41. The ________ keyword indicates that the function is not returning any value.( a. return b. final c. continue d. void)
42. When a primitive data type is passed , it is called by ________.( a. call by reference b. call by value c. call by method
d. none )
43. Variables in the function call are called as _________. (a. parameters b. actual parameters c. formal parameters d.
values)
44. A function returns True or False. The return type of the function is _______. (a. void b. String c. boolean d. int)
45. A function can contain ____ number of return statements (a. 1 b. 2 c. 3 d. As many as the programmer wants.)
46. Function add() can be used only in the same class and takes 2 integer parameters and sends back the sum of the
numbers. Which of the following is a correct prototype for function add(). (a. public static void add( int a , int b) b.
private static void add( int a , b) c. public static int add( int a, int b) d. private static int add( int a , int b) )
47. Function check() takes a char and int parameter, it can be called only by creating an object and can be accessed only
in the package. Which of the following is a correct prototype for function check(). (a. protected static void check(char
ch , int a) b. static void check(char ch , int a) c. void check(char ch , int a) d. public static void check(char ch , int a))
48. Which of the following functions prototype violate the rules of over loading.( 1.void convert(int n1,int n2) 2.int
convert(int n2,int n1) 3.void convert(int n1,int n2,int n3) 4.double convert(double a,double b) )
double convert(int a,int b,int c) (a. 1,2 and 3,5 b. 1,4,3 c. 2,5 and 3,5 d. 1,2)
49.int a[][]={{1,3,5,8},{8,7,6,4}}; Number of bytes reserved?(32,16,8,1}
50. The _______ operator is used to instantiate a class by allocating memory to its object. (a. dot b. new c. this d.static)
51. __________ is a special function which gets executed automatically every time an instance of the class is created.( a.
object b. compiler c. constructor d.function)
52. __________ is the default access specifier.( a. private b. protected c. package d.public)
53. A constructor without any parameters is called as ________ (a. default b. parameterized c. actual d.formal)
54. Data types based on fundamental data types are called as ________.( a. Primitive b. Non Primitive c. reference
d.none)
55._____________ are common to all objects and are shared by all objects (a. instance variables b. class variables c.
global variables d.local variables
56. __________ have fixed memory. (a. fundamental data types b. reference data types c. class d.object)
57. The following statement is an example of ___________ Student s1; (a. Instantiation b. Declaration c. Initialization
d.dynamic initialization)
58. Objects communicate with each other through __________( a. data members b. methods c. fields d.properties)
59. The class from which properties and methods are derived is called _________.( a. derived class b. sub class c. base
class d. class)
60. Constructors can have a return type.( a. true b. false)
61. Constructors can be overloaded (a. true b. false)
62. A member declared as private can be accessed only inside the class and by the subclasses in the same package.( a.
true b. false)
63. Local variables are declared inside a class and are available to all the functions in the class. (a. true b. false)
64. Non static variables can be used in static functions (a. true b. false)
65. An IDE cannot have the main function (a. true b. false )
66. Every class has a constructor. Explicitly defined by the user or implicitly created by the compiler. (a. true b. false)
67.The return type of compareTo() function is (a. boolean b. int c. char d.double)
68. The function equalsIgnoreCase() returns true even if the cases are different (a. true b. false c. none d.0)
69. The String class is present in ______ package (a. util b. lang c. io d.awt)
70. The term OOP stands for ...................................... . (a. Object Oriented Procedure b. Object Oriented Packet c. Object
Oriented Programming d. Object Orientation Procedure)
71. Object Oriented Programming mainly uses ...................................... .( a. Top-down approach b. Top-down and
bottom-up approach c. Bottom-up approach d. None of these )
72. An object belonging to a particular class is known as a/an ...................................... of that class.( a. Interface b.
Instance c. class d. Member)
73. Objects that share the same attributes and behaviour are grouped together into a/an ...................................... .( a.
Interface b. Instance c. Alias d. Class)
74. ...................................... is the technique of binding both data and methods together to keep them safe from
unauthorised access and misuse. (a. Abstraction b. Inheritance c. Encapsulation d. Polymorphism)
75. ...................................... refers to the act of representing essential features without including the background details.
(a. Abstraction b. Inheritance c. Encapsulation d. Polymorphism)
76. Procedure Oriented Programming mainly uses ...................................... .( a. Top-down approach b. Top-down and
bottom-up approach c. Bottom-up approach d. None of these)
77. ...................................... is the feature using which one class acquires the properties of another class.( a. Abstraction
b. Inheritance c. Encapsulation d. Polymorphism )
78. The ability of a method or object to take on multiple forms is called ...................................... . (a. Abstraction b.
Inheritance c. Encapsulation d. Polymorphism)
79. An object has ...................................... . (a. Attributes b. State c. Behaviour d. All of these)
80. A class is ...................................... .( a. An object factory b. A blueprint to create objects c. A specification for objects
d. All of these )
81. ...................................... represents an entity in the real-world with its identity and behaviour. (a. A class b. An object
c. A procedure d. A method )
82. ...................................... is a template to create similar objects that share common characteristics and behaviour. (a.
A method b. A procedure c. An attribute d. A class)
83. The values of an object's ...................................... represent the state of the object. (a. methods b. procedures c.
attributes d. classes )
84. The terms object and ...................................... are often interchangeable. (a. instance b. behaviour c. attribute d.
state)
85. Which best characterizes Procedural Programming? (a. Encapsulation & Objects b. Functions & Procedures c. Classes
& Objects d. Event-Driven & GUI )
86. High-level languages are closer to computer hardware.(true/false)
87. Code and data are held separately in a procedural language. .(true/false)
88. Code and data are held separately in OOP. .(true/false)
89. When you wrap data and related methods into a single unit, it represents encapsulation. .(true/false)
90. A class that is derived from another class is called a subclass. .(true/false)
91. Classes can be derived from other classes. .(true/false)
92. Inheritance allows a class to acquire the properties of another class. .(true/false)
93. A class is a blueprint for the attributes and behaviours of a group of objects. .(true/false)
94. Objects from the same class do not share the same definition of attributes and behaviours. .(true/false)
95. A class is a specification about the object. .(true/false)
96. Only one instance can be created from a single class. .(true/false)
97. A class is a user-defined data type. .(true/false)
98. The terms object and instance are often interchangeable. .(true/false)
99. Collectively, the values of an object's attributes represent the state of the object. .(true/false)
100. Objects interact with each other through messages.(true/false)
101. Which language does the CPU understand? (a. Machine language b. Assembly language c. High-level language d.
English language)
102. Stand-alone Java applications ...................................... for execution.( a. Need Java-compatible web browser b. Need
an assembler c. Do not need Java-compatible web browser d. Need a linker)
103. What is the full form of JVM? (a. Java Visual Monitor b. Java Video Monitor c. Java Virtual Monitor d. Java Virtual
Machine)
104. The full form of JRE is ...................................... . (a. Java Runtime Editor b. Java Runtime Environment c. Java
Runtime Expression d. Java Runtime Enabler)
105. Java uses ...................................... for execution. (a. Compilation and interpretation b. Interpretation c. Compilation
d. None of these)
106. A program that translates code written in a high-level language into machine code is called ......................................
(a. Assembler b. Linker c. Compiler d. None of these )
107. A program that translates an assembly language program into machine code is called ...................................... . (a.
Assembler b. Linker c. Compiler d. None of these )
108. Feature(s) of Java include ...................................... .( a. Robust b. Object oriented c. Secure d. All of these)
109. Java can be used to write ...................................... .( a. Stand-alone applications b. Both stand-alone and internet
applications c. Internet applications d. None of these )
110. Java applications can run on ...................................... .( a. Windows platform b. Macintosh platform c. UNIX platform
d. All of these)
111. Java applications ...................................... . (a. are platform dependent b. do not need a platform to run c. are
platform independent d. cannot run on Windows)
112. A Java program can run as a stand-alone application only if it has ...................................... .( a. a void method b. an
overloaded method c. a main method d. no methods)
113. What is the extension of a Java source code file? (a. java b. .txt c. .class d. .BlueJ )
114. What is the extension of a Java class file? (a.obj b. Java c. .class d. .BlueJ )
115. Choose the correct statement. (a. Applets can be executed in a web browser only. b. Applets can be executed in an
applet viewer only. c. Applets can be executed in both web browser and applet viewer. d. Applet cannot be executed.)
116. Java uses ...................................... character set. (a. ASCII only b. Extended ASCII only c. Unicode d. None of these)
117. ASCII stands for ...................................... . (a. American Standard Code for Information Interchange b. American
Simulated Code for Information Interchange c. American Standard Code for Interchange of Information d. American
Standard Code for Interaction of Information )
118. ASCII is ...................................... . (a. 6-bit set of codes b. 8-bit set of codes c. 7-bit set of codes d. 16-bit set of
codes )
119. Extended ASCII is ...................................... .( a. 6-bit set of codes b. 8-bit set of codes c. 7-bit set of codes d. 16-bit
set of codes )
120. The smallest individual component in a program is called ...................................... .( a. Token b. Identifier c. Keyword
d. Method Values and Data Types)
121. Which of the following is not a token?( a. Keyword b. Identifier c. Operator d. Procedure)
122. Which of the following is a keyword? (a. character b. break c. object d. attribute)
123. Which of the following is not a legal identifier? (a. _room b. $Pay Amount c. 10thClass d. nullValue)
124. Which of the following is a default value of float data type?( a. 0 b. 0float c. Of d. 0.0f )
125. Which of the following is a default value of boolean data type? (a. true b. false c. null d. void )
126. Which of the following is an invalid integer? (a. 2222 b. 22222 c. 222 22 d. 222)
127. Which of the following is not a character literal? (a. '\n' b. "n" c. 'n' d. All of these)
128. Which of the following punctuator is the statement terminator in Java?( a. ; b. , c. . d. All of these)
129. Which of the following is not a primitive data type in Java?( a. boolean b. short c. float d. class)
130. What is the size of a long data type in Java?( a. 32 bits b. 64 bits c. 48 bits d.16 bits
131. Long data type is not supported in Java.(true/false)
132. What is the size of a boolean data type in Java? (a. 1 bit b. 16 bits c. 8 bits d. 2 bits)
133.boolean data type does not take any space in memory.(true/false)
134. Single line comments can be added using ...................................... . (a. II b. /*......*/ c. // d. None of these)
135. Which of the following changes a variable declaration into a constant? (a. const b. constant c. static d. final )
136. The ASCll codes of A-Z are represented by decimal range ...................................... .( a. 65-90 b. 66-91 c. 97-122 d.
98-123)
137. Which of the following is a primitive data type?( a. array b. interface c. class d. boolean)
138. Java supports the use of the ASCII character set only. .(true/false)
139. The ASCll code for character 'Z' is 90. .(true/false)
140. The smallest unit in a Java program is known as token. .(true/false)
141. The Unicode character set uses 8 to 32 bits per character. .(true/false)
142.In an escape sequence, a character is preceded by a backward slash (\)..(true/false)
143. In Java, an identifier can begin with a $ sign. .(true/false)
144. The boolean data type is used for storing logical values. .(true/false)
145. Identifiers in Java may be of any length. .(true/false)
146. The char data type reserves 8 bits in memory. .(true/false)
147. Default value of reference data type is null. .(true/false)
148. To designate a literal constant of the type float, you must append the letter L to it. .(true/false)
149. Default value of char data type is '\u0000'. .(true/false)
150. If a literal constant contains a decimal point, then it is of the type double by default. .(true/false)
151. If a = 8 and b = 4, the value of a %= b is ...................................... . (a. 2 b. 0 c. 4 d. 8 )
152. An operator taking only single operand for its operation is called ...................................... . (a. A unary operator b. A
binary operator c. A ternary operator d. None of these )
153. Which one of the following is not a binary operator? (a. && b. % c. == d. ! )
154 . Which one of the following is not a valid operator in Java? (a. <= b !== c. != d. ==)
155. The statement i = i + 1 is equivalent to ...................................... .( a. i++ b. i += 1 c. ++ i d. All of these)
156. for x = 5, the statement sum = ++x + 8 evaluates to ...................................... .( a. sum= 12 b. sum= 13 c. sum= 14 d.
sum= 15)
157. The statement (1 >0) || (1<0) evaluates to-(a. 0 b. 1 c. false d. true)
158. The statement (1 == 1 )? 1 : 0 evaluates to ...................................... .( a. 0 b. 1 c. false d. true)
159. The expression 17 % 4 gives the output ...................................... . (a. 4 b. 3 c. 2 d. 1 )
160. Consider the following code snippet: float x = 8.25F; int y; y = (int) x; What are the values of x and y? (a. x = 8.25, y =
8 b. x = 8.0, y = 8.0 c. X = 8, y = 8.25 d. x = 8, y = 8)
161. The expression 13 / 3 gives the output ...................................... . (a. 4 b. 3 c. 0 d. 1)
162. The statement System.out.println("six" + 3 + 3); gives the output ...................................... . (a. six33 b. six6 c. 33six d.
6six)
163. The expression 4 + 8 % 2 gives the output ...................................... .( a. 6 b. 8 c. 4 d. None of these )
164. Implicit type conversion is also known as ...................................... . (a. Automatic type conversion b. Type promotion
c. Widening conversion d. All of these)
165.There is only one ternary operator in Java.(true/false)
166. Arithmetic operators + and - also have a unary form. (true/false)
167. Operators = and == perform the same operation in Java. (true/false)
168. The expression 14 % 2 evaluates to 0. (true/false)
169. The expression 7 / 13 evaluates to 0. (true/false)
170. The output of System.out.println (!true); is false. (true/false)
171. The expressions 6 + 7 and "6" + "7" evaluate to the same value. (true/false)
172. The expression m = m + 2 is same as m = + 2. (true/false)
173. The new operator allocates memory during runtime. (true/false)
174. The statements n = 25 and n = = 25 are same. (true/false)
175. The expression p =- 9 is same as p = p-9. (true/false)
176. The assignment operator (=) is a binary operator. (true/false)
177. The output of System.out.println(1 = = 1); is true. (true/false)
178. Explicit type conversion is also known as coercion. (true/false)
179. A method that does not return a value has a ...................................... return type.( a. double b. class c. float d. void )
180. A method can return ...................................... . (a. any number of values b. 2 values c. only 1 value d. 3 values )
181. If a method returns a value, then it must be ...................................... . (a. of the same data type as defined in its
prototype b. void type c. double type d. boolean type )
182. Parameters in the method definition are called ...................................... . (a. actual parameters b. formal parameters
c. informal parameters d. void parameters)
183. The parameters that are passed to the method when it is invoked are called ...................................... . (a. formal
parameters b. actual parameters c. informal parameters d. void parameters)
184. The method that changes the state of an object is known as ...................................... . (a. pure method b. impure
method c. perfect method d. imperfect method)
185. The scope of a local variable is limited to the ...................................... . (a. Windows b. Multiple programs c. Class d.
Method or block it is declared in )
186. The technique in which the change in the formal parameter gets reflected in the actual parameter is known
as ...................................... . (a. call by reference b. call by value c. call by argument d. call by method)
187. In which technique are the values of actual parameters copied to the formal parameters? (a. call by reference b. call
by value c. call by argument d. call by method )
188. A method with many definitions is known as ...................................... .( a. many method b. multiple method c. void
method d. overloaded method)
189. A method may contain any number of return statements.(true/false)
190. The non-static methods need an instance to be called. .(true/false)
191. A method can return more than one value. .(true/false)
192. Methods defined as void must return a value. (true/false)
193. The static methods need an instance to be called. .(true/false)
194. In Java, all primitive types are passed by value and all reference types are passed by reference. .(true/false)
195. You can place the return statement in a void method without any expression. .(true/false)
196. If a method returns a value, then it must be of the same data type as defined in the method prototype. .(true/false)
197. Parameters in the method definition are called dummy parameters. .(true/false)
198. Methods reside in a class in Java. .(true/false)
199. Method overloading is one of the ways by which Java implements polymorphism. .(true/false)
200. The scope of a local variable is limited to the method or the block it is declared in. .(true/false)
201. The keyword static makes a method a class method. .(true/false)
202. An impure method always returns the same value when the same arguments are given. .(true/false)
203.A programmer wrote the following statement: netPay = grossPay + providentFund; instead of: netPay = grossPay -
providentFund; Assuming all the unseen code is correct, what kind of error is it? (a. Syntax error b. Runtime error c.
Logical error d. None of these)
204. Which of the following might make the Java compiler report a syntax error in a particular line of a program? (a. The
program is typed in the wrong font. b. The line contains a comma (,) instead of a dot (.). c. It is caused by Java runtime. d.
Program takes too long to compile.)
205. Which of the following statement is true for logical errors? (a. The compiler does not detect these errors. b. There is
no indication of error when the program is executed. c. The program may produce correct results for some input data
and wrong results for other input data. d. All of the above )
206. Which keyword do you use to include a class in your program? (a. import b. export c. include d. impart)
207. Which of the following is not a valid method of the Scanner class? (a. next() b. nextlnt() c. nextLong() d.
nextNumber())
208. Default delimiter used in the Scanner class is ...................................... . (a. Comma b. Whitespace c. Colon d. There is
no default delimiter. )
209.Which package would you import to display the date and time?( a. java.util .* b. java.Date.* c. java.io.* d.
java.lang.*)
210. Which package would you import for the Scanner class?( a. java.util .* b. java.awt.* c. java.io.* d. java.lang.*)
211. Errors occur in a program when ...................................... . (a. Syntax of the programming language is not followed.
b. The program does not run properly or does not execute at all. c. The program produces an incorrect result. d. All of
the above)
212. The Scanner class can be used to read input from ...................................... . (a. a keyboard b. a file c. a string d.all of
these)
213.What will be the output of Math.cbrt(–125)? (a. 5.0 b. 0.0 c. –5.0 d. error - can't use Math.cbrt0 on a negative
number)
214. Which Java package includes the Math class? (a. java.io b. java.lang c. java.util d. java.system
215. Give the output of Math.sqrt(x); when x = 9.0 (a. 3 b. 3.0 c. 3.00 d. All of these)
216. Give the output of Math.ceil(–0.6). (a. –1.6 b. –1.5 c. –0.0 d. –0.0 5. )
217.Give the output of Math.ceil(–46.6). (a. –46.6 b. –46.5 c. –1.0 d. –46.0)
218. Give the output of Math.abs(x); when x = –9.99 (a. –9.99 b. 9.99 c. 0.99 d. None of these)
219. Which of the following is a method to find the square root of a number?( a. Find Squareroot(x) b. Sqrt(x) c.
Math.Square(x) d. Math.sqrt(x))
220. What will be the output of Math.pow(3, 0)? (a. 0.0 b. 1.0 c. 3.0 d. –1.0)
221. Math.random() returns a double value r such that ...................................... . (a. 0.0 ≤ r < 1.0 b. 0.0 ≤ r ≤ 1.0 c. 0.0 < r
≤ 1.0 d. 0.0 < r < 1.0 )
222. What will be the output of Math.floor(-20.10)? (a. –20.0 b. –21.0 c. 20 d. 21)
223. What will be the output of Math.round(0.5)? (a. 0.0 b. 0 c. 1 d. 1.0)
224. What will be the output of Math.abs(–0)?( a. 0.0 b. 0 c. –0 d. +O)
225. Given the following statements: int min = 1, max= 10; int range= max – min + 1; int num = (int) (range *
Math.random() + min); The value of num will be in integer such that ...................................... .( a. 1 <= num <= 10 b. 1 <=
num < 10 c. 1 < num <= 10 d.1<num < 10)
226.Which of the following are conditional constructs?(a. if-else b. if-else-if ladder c. switch statement d. All of these )
227. Which operator cannot be used with if-else statement?( a. <= b. II c. && d. ? : )
228. What will be the output of the following code? int size= 2; if (size < 0) System.out.println("Small"); else if (size= = 0)
System.out.println("Medium"); else System.out.println("Large"); (a. Small b. Large c. Medium d. Runtime error)
229. What will be the output of the following code? int fruit = 3; switch (fruit + 1){ case 1: System.out.print! n("
Banana"); break; case 2: System.out.println("Apple"); break; case 3: System.out.println("Orange"); break; default:
System.out.println("Fruitless"); } (a. Orange b. Banana c. Apple d. Fruitless)
230. Predict the output of the following code snippet: int a= 1; int b = 2; if (a== b) System.out.println ("Both values are
equal"); else System.out.println ("Values are not equal"); (a. Both values are equal b. Incorrect use of the = = operator c.
Values are not equal d. No output )
231. Consider the following code snippet: if ( c > d) x = c; else x = d; Choose the correct option if the code mentioned
above is rewritten using the ternary operator: (a. x = (c >d)? c : d; b. x = (c >d)? d : c; c. x = (c >d)? c : c; d. x = (c >d)? d :
d; )
232. if ((a > b) && (a > c)), then which of the following statements is true? (a. a is the largest number. b. b is the largest
number. c. c is the largest number. d. b is the smallest number. )
233. Consider the following code snippet: int val= 2; switch (val) { case 1: "System.out.println("Case 1 "); break; case 2:
"System.out.println("Case 2"); break; default: "System.out.println("No match found"); break; } Which of the following
statements is correct? (a. case 1 will be executed. b. case 2 will be executed. c. default will be executed. d. both case 1
and 2 will be executed.)
234. A sequence of statements enclosed between a pair of curly brackets is called ...................................... . (a. a
compound statement b. an empty statement c. a null statement d. a void statement )
235. Which clause is optional in the switch statement?( a. default b. case c. switch d. None of these )
236. Which of the following statements involves a fall-through? (a. if-else b. for loop c. if-else-if ladder d. switch)
237. Which of the following causes a fall-through in the switch statement? (a. Omission of fall b. Omission of continue c.
Omission of break d. Omission of loop )
238. Which of the following is mandatory in the switch statement?( a. break b. continue c. case d. default )
239. Which of the following statement is a valid combination? (a. if inside switch b. switch inside if c. else inside switch d.
default inside if)
240. Which of the following segment can be omitted in a for loop?( a. Initialisation b. Test condition c. Update
expression d. All of these)
241. Which of the following loop executes at least once?( a. while b. for c. do-while d. None of these)
242. Which of the following is an exit-controlled loop? (a. while b. do-while c. for d. None of these)
243. Which of the following is an invalid loop?( a. repeat b. for c. do-while d. while)
244. Which of the following statement causes complete termination of the loop? (a. continue b. jump c. break d.
terminate)
245. Which of the following is an empty loop? (a. for (i = 0; i < 5; i++); b. while (i < 5) i++; c. do {i++;} while (i < 5); d. All of
these )
246. Which of the following is not a jump statement in Java? (a. break b. jump c. return d. continue)
247.How many times will the following code print "Java"? for (int i= 1; i <= 5; i ++); { System.out.println( "Java"); } (a. 0 b.
1 c. 5 d. 4 9)
248.What will be the output of the following code? public static void main(String args[]) { int sum = 0; for (int i= 1; i <= 5;
i ++) { sum= i; } System.out.println( sum); }( a. 15 b. 21 c. 5 d. 0)
249. How many times will the following loop execute? public static void main(String args[]) { int sum = 0; for (int i= 10; i >
5; i++) { sum += i; } System.out.println(sum); } (a. 5 b. 0 c. 15 d. Infinite loop)
250. Which of the following for loops will cause the body of the loop to be executed 10 times? (a. for (int i= 0;i < =10; i+
+ ) b. for (int i=1;i>10 ; i-- ) c. for (int i= 10; i >1 ; i-- ) d. for (int i= 0;i< 10) if (i + + % 2 == 0) System.out.println(i); })
251.The while loop is an exit-controlled loop.(true/false)
252. To execute a do-while loop, the condition must be true in the beginning. .(true/false)
253. The while part of a do-while statement must be terminated by a semicolon. .(true/false)
254. All types of loops in Java (for, while, and do-while) can be infinite loops. .(true/false)
255.What is a nested loop in Java?( a. A loop with a fixed number of iterations b. A loop inside another loop c. A loop
that runs only once d. A loop with a conditional statement)
256. What is the primary purpose of using nested loops? (a. To increase the complexity of the code b. To reduce the
execution time c. To iterate over elements of an array or collection d. To create an infinite loop)
257. Which keyword is used to break out of the innermost loop in a nested loop structure? (a. exit b. break c. terminate
d. escape )
258. In a nested loop, if the outer loop has 'm' iterations and the inner loop has 'n' iterations, how many total iterations
will be performed?( a. m b. n c. m * n d. m+n)
259. A member method having the same name as that of the class is called ...................................... (. a. an alias b. a
friendly method c. a constructor d. a protected method )
260. A constructor has ...................................... return type. (a. a void b. more than one c. String[] args d. no)
261. A constructor is used when an object is ...................................... .( a. created b. destroyed c. assigned a value d.
abstracted )
262. A default constructor has ...................................... .( a. no parameters b. one parameter c. two parameters d.
multiple parameters)
263. Pick the correct answer. (a. A constructor has exactly the same name as its defining class. b. A constructor method
does not have a return type. c. A constructor can be invoked only via the new operator. d. All of these)
264. In constructor overloading, ...................................... .( a. All constructors must have the same name as that of the
class. b. All constructors must have the same number of arguments. c. All constructors must have arguments of type
String[] args. d. All constructors must have no arguments.)
265.Which of the following is a primitive data type?( a. int b. float c. char d. All of the these )
266. Which of the following is a composite data type?( a. int b. float c. char d. String)
267. The return type of the isLowerCase() method is ...................................... .( a. int b. boolean c. char d. String)
268. The return type of the toLowerCase() method is ...................................... .( a. int b. boolean c. char d. String)
269. The value returned by Integer.parseInt("–321") is ...................................... . (a. –321 b. 321 c. 321.0 d. "321")
270. Name the method that can convert a string into its integer equivalent.( a. Integer.parseInteger() b. Integer.getlnt()
c. Integer.parseInt() d. Integer.readInt() )
271. In which package is the wrapper class Integer available?( a. java.io b. java.util c. java.awt d. java.lang)
272. What will be the result when the following statement is executed? int count = new Integer(12); (a. Variable count
will be initialised with value 12. b. Variable count will be initialised with default value of int, i.e., zero (0). c. An array
count will be initialised with 12 elements, all having a default value of zero (0). d. Value of count will be unknown as no
value has been assigned yet)
273. A member variable declared with a public access specifier has visibility in ...................................... . (a. Class b.
Package c. Subclass d. All of these)
274. A member variable declared with a private access specifier has visibility only in the ...................................... .( a.
class b. Package c. Subclass c. All of these )
275. A member variable declared with no access specifier has visibility in ...................................... .( a. Class and package
b. Class, package and subclass c. Class and subclass d. Class )
276. An instance variable ...................................... .( a. needs an instance to access it b. does not need an instance to
access it b. does not need an instance to access it c. can be accessed using the class name d. is declared with the static
keyword)
277. A static variable ...................................... . (a. is preceded by static keyword in the declaration b. is accessed via the
class name c. is also known as a class variable d. All of the above)
278. ...................................... is the feature by means of which one class acquires the properties of another class. (a.
Abstraction b. Inheritance c. Encapsulation d. Polymorphism)
279. The class that gets inherited is known as ...................................... .( a. Parent class b. Base class c. Super class d.
Subclass)
280. When many sub classes are inherited from a single base class, it is known as ...................................... . (a.
Hierarchical inheritance b. Multiple inheritance c. Single inheritance d. Multilevel inheritance )
281. The size of an array that signifies the number of elements it can store is given using ......................................
brackets. (a. {} b. [] c. () d. All of these )
282. Given array int x[] = {11, 22, 33, 44}; the value of x[1] is ...................................... .( a. 11 b. 22 c. 33 d. Invalid value)
283. Given array int x[] = {11, 22, 33, 44}; the value of x[1+2] is ...................................... . (a. 11 b. 22 c. 33 d. 44)
284. If int arr[] = {3, 5, 7, 9}; what is the value of arr.length? (a. 3 b. 5 c. 4 d. Cannot be determined)
285. Given array int z[] = {15, 16, 17}; It will occupy ...................................... bytes in memory. (a. 3 b. 12 c. 24 d. 64)
286. A linear search ...................................... . (a. can be used with sorted arrays only b. can be used with unsorted arrays
only c. can be used with both sorted and unsorted arrays d. cannot be used with arrays)
287.A binary search ...................................... . (a. can be used with sorted arrays only b. can be used with unsorted arrays
only c. can be used with both sorted and unsorted arrays d. cannot be used with arrays)
288. Which of the following statements is true?( a. Binary search is less efficient than the sequential search. b. Binary
search is less efficient than the linear search. c. Binary search is more efficient than the sequential search. d. Binary
search is as efficient as the sequential search.)
289. In ...................................... search, the algorithm uses the middle value of the array for the search operation.( a.
Binary b. Linear c. Bubble d. Selection )
290. Which element is num[9] of the array num? (a. 8th b. 9th c. 10th d.11th)
291.The trim() method of the String class removes ...................................... .( a. leading spaces only b. trailing spaces only
c. spaces in between words d. leading and trailing spaces)
292. While using the toLowerCase() method on a string containing special characters, ...................................... . (a. the
special characters remain unaffected. b. the special characters are converted to spaces. c. the special characters are
converted to null character. d. the special characters are removed from the string. )
293. The index of a string ...................................... . (a. ranges from 0 to the length –1 of the string b. ranges from 0 to
the length of the string c. ranges from 1 to the length of the string d. ranges from 1 to the length –1 of the string )
294. The indexOf( ) method returns the position of the ...................................... . (a. first occurrence of the specified
character b. last occurrence of the specified character c. null character d. '\n' character)
295. The return type of the equals() method is ...................................... . (a. int b. char c. boolean d. void )
296. Which one of the given statements is true for the following statement? string1.compareTo(string2) (a. if string1 >
string2 the result will be a negative integer i.e. < 0. b. if string1 > string2 the result will be a positive integer i.e. > 0. c. if
string1 > string2 the result will be 0. d. None of the above )
297. Which one of the given statements is true for the following statement? string1.compareTo(string2) (a. if string1 >
string2 the result will be a positive integer i.e. > 0. b. if string1 < string2 the result will be a negative integer i.e. < 0. c. if
string1 = string2 the result will be 0 i.e. = 0. d. all of these)
298. The valueOf() method returns the ...................................... .( a. string representation of the argument b. int
representation of the argument c. boolean representation of the argument d. character representation of the
argument )
299. Output of the following statement is ...................................... . System.out.print!n("SUNDAY".substri ng(3)); (a. NDA
b. DAY c. SUN d. N)
300. Output of the following statement is ...................................... . System.out.println("WONDERFUL".substring(3,4)); (a.
DERF b. NDER c. D d.N)
301.The ‘new’ operator is used to allocate dynamic memory for:( (a) Arrays (b) Objects (c) Primitive variables (d) Both a
and b )
302. The term given to the non-graphic characters that control the way how data gets printed on an output device is:
((a) Identifier (b) Unicode (c) Punctuators (d) Escape sequence )
303. Which operation will be performed at first in the statement ++i<=20; ? ((a) Comparison (b) Increment (c) Both a and
b (d) None of these )
304. for(int x = -1; x<=5; x++); The above statement can be termed as: ((a) Null loop (b) Empty loop (c) Body less loop (d)
All of these)
305. The type of operators that is used to define a basic conditional expression is: ((a) Relational (b) Logical (c) Ternary
(d) All of these)
306.( What will be the return data type and the result produced by the following statement ? Math.round(7.5f) +
Math.rint(6.5); (a) int, 15 (b) long, 14 (c) double, 14.0 (d) float, 15.0f )
307. Identify the error: System.out.println ((8 - 8) * 8 / 8 - 8); ((a) Runtime (b) Syntax (c) Logical (d) No error )
308. Wrapper classes are part of ______ package. ((a) java.io (b) java.awt (c) java.net (d) java.lang)
309. Which of the following library functions returns a boolean type value ? 1. Character.isDigit() 2. equals() 3.
nextBoolean() 4. Character.isLowerCase() ((a) 1 and 2 (b) 2 and 3 (c) 3 and 4 (d) All of these )
310. Reducing complexity, reusability and simple interface are the features of: ((a) Methods (b) Classes (c) Packages (d)
Java programs )
311. The number of bytes occupied by an array containing 5 characters is: ((a) 80 (b) 40 (c) 10 (d) Undefined)
312. The return data type of Math.abs() method is:( (a) double (b) int (c) long (d) depends upon the data type of
arguments)
313. Predict the output: System.out.println("MACHINE".indexOf('m')); ((a) 0 (b) 1 (c) -1 (d) Syntax error)
314. Assertion (A): No side effect occurs in pure functions. Reason (R): The attributes of the passed object remain
unchanged. (a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A) (b)
Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion (A) (c) Assertion (A) is
false and Reason (R) is true (d) Assertion (A) is true and Reason (R) is false
315. Go through the following text and choose the correct answer: A for loop allows more than one initialisation of
variables as well as more than one variable updation. Initialisation in a for loop may be outside the loop block and
updation may be used in the body of the loop. The updation of a loop control variable in a for loop can be done: (a) in its
header (b) in its body (c) outside the loop (d) Both a and b
316. Assertion (A): Global variables of a class can be accessed from any method defined within the the same class.
Reason (R): Global variables are declared explicitly within all methods of a class. (a) Both Assertion (A) and Reason (R)
are true and Reason (R) is a correct explanation of Assertion (A) (b) Both Assertion (A) and Reason (R) are true and
Reason (R) is not a correct explanation of Assertion(A) (c) Assertion (A) is true and Reason (R) is false (d) Assertion (A) is
false and Reason (R) is true
317. Which among the following access specifier allows accessibility outside that package ? (a) public and private (b)
public and protected (c) public and friendly (d) private and protected
318. Identify the error message which displays, if the following statement is executed: byte x[4] = {2, 4, 7, -8}; (a)
Insufficient cells (b) Array index out of bounds exception (c) Elements exceeding cells (d) None of these
319. Given that int z[ ] [ ] = {{5, 7, 3}, {4, 8, 0}}; What will be the value of z[1][0] and z[0][2] ? (a) 4 and 3 (b) 5 and 5 (c) 3
and 0 (d) 4 and 7
320.Which of the following is the correct statement to store 35 integers? ((a) int x[35] = new int[]; (b) int x[] = new
int[35]; (c) int x[35] = new int[35]; (d) int x[] = new int[34]; )
321.Consider the following statement- private int x,y; Can the x and y be accessed from another class? ((a) Yes (b) No (c)
May be (d) if they accessed from protected class.)
322. II operator has ____ precedence than && operator. ((a) lower (b) higher (c) equal (d) None)
323. How many constructors can a class have? ((a) 0 (b) 1 (c) 2 (d) Any number )
324. What is the output: System .out.print("NAMASTEY" .compare To("Namaste") ); ((a) false (b) true (c) 32 (d)-32 )
325. What will be the output for the following code: int a=10, b=15; while(++a < - -b) System .out.print(b );
System.out.print(a); ((a) 131314 (b) 141413 (c) 141313 (d) 141312)
326. Corresponding wrapper class of char data type is __ ((a) Char (b) Character (c) CHAR (d) CHARACTER)
327.A data type which contains occupies 32 integer as well as fractional part and occupies 32 bits space is_ ((a) double
(b) int (c) float (d) byte )
328. State the output of the following: for(int i=1, j=1; i<=2; i++) System.out.print(i + ” ”+j + “**”);( (a)1 1**2 1** (b)1 1
**2 2** (c)2 2**1 1** (d)1 2**2 3**)
329. Static variables are also called ((a) Local variables (b) Class variables (c) Final variables (d) Instance variables)
330. A class implements which of the following OOP characteristics?( (a)Encapsulation (b)Inheritance (c)Abstraction
(d)Polymorphism)
331. State the output of the following : double x=-3.142; · int y=(int) Math.abs(x) +(int)x; System.out.print(y); ((a)0
(b)6.284 (c)6.0 (d)-6)
332. State the output of the following : System.out.print("Save electricity and water".indexOf('b') + 1 ); ((a)3 (b)0 (c)1 (d)-
1)
333.What is the return type of the method endsWith()?( (a)Int (b)char (c)boolean (d)String )
334.Practical implementation of polymorphism in java is( (a)method overloading (b)method calling (c)method prototype
(d)method signature )
335.___ searching is faster when the arrays are very lengthy ((a)Linear (b)Bubble (c)Binary (d)Selection)
336. How many boolean literals are there in java? ((a)0 (b)1 (c)2 (d)3)
337. Method which converts String to int (a) parselnteger() b) toString() c) parselnt() d) tolnt() )
338.The arguments used in the calling ·method are called? (a) Actual parameters b) Formal.parameters c) Virtual
parameters d) Real parameters )
339.The array char P[]={'a','b'}; occupies (a) 2 bytes b) 4 bytes c) 8 bytes d) 6 byte)
340. Which of the following is known as Object Code?(1. The program file containing the actual instructions in Java,2.
The output of the compiler after a processes source code,3. The bytecode we get after compiling the source code using
javac compiler,4. None of the above)
341. The blueprint from which objects are created in Java is known as .(1. Interface,2. Package,3. Class,4. Language)
342.Operators with higher precedence are evaluated before operators with relatively lower precedence.Arrange the
operators given below in order of higher precedence to lower precedence.(i) || (ii) % (iii) && (iv)- -(1. (iv), (i), (iii), (ii),2.
(iv), (iii), (ii), (ii),3. (iv), (ii), (iii), (i),4. (i),(ii),(iii),(iv))
343. What is the value returned by the following line in Java? Math.floor(-7.912);(1. -7,2. -8.0,3. -7.0,4. None of the
above)
344. What is being done in the following code snippet?
int n=10; System.out.print(n);
if(n==10) {
n=20;
System.out.print(n);
}
System.out.print(n);(1. 10 10 10,2. 10 20 20,3. 10 10 20,4. 0 10 0)
345. ------------- is defined as an act of representing the essential features without knowing the background
details.(1. Inheritance,2. Polymorphism,3. Encapsulation,4. None of the above)
346.The number of bits occupied by short data type is -------------bits.(1. 8,2. 16,3. 32,4. 64)
347.-----------data type are pre-defined or built-in data type because the system developers of Java have
defined them.(1. Non-primitive,2. Primitive,3. Both Primitive or non-primitive,4. None of the above)
348. Data conversion in which the data type of the result in a mixed mode expression gets converted into
a specific type as per user’s choice. (1. Implicit Conversion,2. Explicit Conversion,3. Default,4. None of the above)
349.Method that accepts a string without any space is ---------(1. nextLine(),2. next(),3. Next(),4. nextint())
350.The default initial value of boolean data type. (1.true 2.1 3. false 4.0)
351.Identify the category of the loop given below:-for(int i=1;i<=10;i++){}(1. Infinite Loop,2. Finite Loop,3. Null Loop,4.
Empty Loop)
352.A function which returns a value to its caller module. It also doesn’t change the states of an object.(1. Impure
Methods 2. Mutator3. Pure Function 4. Accessor Method)
353. The type of variable which is a common copy for each object.(1. Class Variables 2. Instance variables 3. Static
Variables
4. none)
354. A constructor that is used to initialize the instance variables of an object by copying the initial values
of the instance variables from another object .(1. Non-parameterized constructor 2. Constructor 3. Parameterized
constructor
4. Copy Constructor)
355. Constructors doesn’t need to be called in the main method.(true/false)
356. A package is a collection of data.(true/false)
357 A function with the same name but with similar types of arguments are known as function
overloading. .(true/false)
358. The function System.exit(0) which is used to terminate the execution at any instance of the program. .(true/false)
359. Run time error occurs at compile time when the compiler does not respond properly while executing
a statement. .(true/false)
360.Choose the odd one out:-(1. * 2. + 3. % 4. &&)
361. Choose the odd one out:-(1. Break statement,2. Return,3. Continue Statement,4. while loop)
362.Choose the odd one out:-(1. Return Type 2. Local Variables 3. Parameter List 4. Access Specifier)
363. Choose the odd one out:-(1. Nested Member Methods 2. Private 3. Public 4. Protected)
364. Choose the odd one out:-(1. java.util 2. java.io 3. java.Math 4. java.lang)
365. What is the output of the following snippet?
char c=’A’;short m=26; int n=c+m; System.out.println(n);(1. 26 2. A 3. A914. 91)
366. int x=4, y=8,z=0; z*=--y- y--+ ++y+x++ - ++x; System.out.println(x+ “ “+y);(1. 7 7 2. 6 7 3. 6 6 4. 0 6)
367.Attributes of an object are also known
as- (methods,properties,classes,functions)
368.Which of the following is the process where an object of one
class receives the properties of objects of another class? (encapsulation
,polymorphism,inheritance,modularity)
369.What is the main goal of Object oriented
programming?(ease of evolution,monitoring
maintenance,encapsulating code,information hiding
370.Polymorphism relatedto-(PPO,class,OPP,OOP)
371.Which from the following is a feature that allows us to perform
a single action in different ways.(Abstraction,Polymorphism,Encapsulation,Inheritance)
372.Pick the term that relates to polymorphism-
(Dynamic binding,static allocation,dynamic
allocation,static binding)
373.Which of the following is not a part of OOP? (Information hiding
Multitasking,Polymorphism,Inheritance)
374.Hiding complexity can also be termed as-(Inheritance,Overloading, Data
binding Abstraction)
375.Which of the following concepts of OOPS means exposing only
necessary information to client? (Encapsulation,Abstraction,Data Hiding,Data binding)
376.How many objectscan be made from a class?(
None, you make classes from objects,one,As many as
you want, all of the above )
377. int k=0; for(int j=0;k++<=10;)System.out.print(k);(1. 0 2. Error 3. 1 2 3 4 5 6 7 8 9 10 11 4. None)
378. int p=100, q=200; boolean r=(p==q); System.out.println(r);(1. 0 2. false 3. True 4. Error)
379.Predict the output - System.out.println(“Year”+21+22);(1. Year 21 22 2. Year 43 3. Year2122 4.error)
380.The wrapping up of data and functions into a single unit is called-(a) Encapsulation b) Inheritance c) Polymorphism
d) Abstraction)
381.Which of the loops will be executed at least once even if the condition is false?(a) while loop b) do – while c) for
loop d) switch)
382. If the function does not return any value, then what is the return type?(a) int b) double c) void d) char)
383.When will be the constructor created automatically?(a) When the class is created b) When the object is created c)
When the program ends)
384. The template or blue print used to create objects-(a) class b) functions c) data d) Packages)
385.______________ function is used to find maximum of two numbers (a) Math.min( ) b) Math.max( ) c) Math.sqrt( ) d)
Math.log( ))
386. Multiple branches are used by ____________ statement.(a) while loop b) do – while c) for loop d) switch)
387. ______________ keyword is used to return a value from a function.(a) send b) sends c) return d) returns)
388. Java constructor is like a method without _____________________(a) arguments b) return type c) statements d)
data)
389. The parent class is also called as ___________________(a) base class b) main class c) derived class d) important
class)
390. The default package used in java-(a) java.util b) java.Math c) java.lang)
391. The operator used to find remainder after dividing two numbers-(a) ++ b) % c) & d)?;)
392. Invoking a function means-(a) Calling a function b) Defining a function c) creating a function d)reusing a function)
393. The constructor with parameters is-(a) Default constructor b) parameterized c) non-parameterized d)none)
394. A bundle of similar classes-(a) Package b) user defined classes c) system class)
395. A loop in java generally contains a loop counter(true/false)
396. The output of logical || is true if both are false(true/false)
397. All user defined functions cannot take parameters. (true/false)
398. Constructors are both user defined and compiler created. (true/false)
399. The private members of the class can be used outside the class. (true/false)
400.Choose the odd one out:- a) for b) while c) do – while d) if
401. Choose the odd one out:- a) increment operator b) decrement operator c) arithmetic d) unary plus
402. Choose the odd one out:- a) function b) method c) block of code d) package
403. Choose the odd one out:- a) actual parameter b) formal parameters c) class variables d) constants
404. Choose the odd one out:- a) polymorphism b) abstraction c) many forms d) function overloading
405. for (int i = 0; i<10; i++) { x = x+i;} The output is?(a) 23 b) 45 c) 46
406. for (int i = 1; i<=5; i++) { System.out.println(“Hello”)} How many times loop executed?a) 5 b) 3 c) 4
407. int change (int p, int q) { p = p * q; return p} What is the output of the above function if called
change(10, 11) ? a) 10 b) 11 c) 110
408. class B { int b; B( ) { b = 25;} void display( ){ System.out.println ( b); }a) no output b) 25 c) compile time error
409. class abc { int a;int b; void print ( ) { System.out.print ("a=" + b); System.out.println("b="+ a); } }when
the function is called with values a = 15, b = 16 what is the output?a)a=15b=16 b)b=16a=15 c) error
410. Which of the following function changes the state of an object?a) Pure functions b) Impure functions
c) Abstract functions d) Nested functions
411. Which of the following access specifier gives maximum accessibility?a) public b) private c) protected d) None of
these
412. How many values can a function return?a) 0 b) 1 c) both a and b d) 2
413. What type of variables are shared by all the objects of that class?a) Class variables b) Instance variables c) Counter
variables d) flag variables
414. Which principle of OOPs is implemented by function overloading?a) Encapsulation b) Polymorphism c) Data
abstraction d) Dynamic binding
415. Changes made by a function to a static variable are ______________.a) not reflected in other functions b) reflected
in other functions c) partially reflected in other functions d) none of these
416. Choose the odd one out a) Token b) Literals c) Identifiers d) operators
417. == is a ____________ operator.a) assignment b) relational c) conditional d) none of these
418. Which function of Scanner class is used to input a sentence from the user? a) next() b) nextLine() c) read() d)
readLine()
419.Which variable of following data types occupies maximum memory space? a) char b) int c) double d) float
420. Which among the following is a valid float literal? a) 12.36f b) 12.36Fc) 12.36 d) Both a and b
421. Choose the correct answer:int c=0;for(int i=1;i<=10;i++)for(int j=1;j<=10;j+=2)c++;System.out.println(c); a) 100 b) 50
c) 5 d) 10
422. Choose the correct answer from the code snippet given below:-String a=(marks > 90) ? “A”: (marks >= 80) ? “B” :
“C”; if marks=85 a) A b) B c) C d) error
423. Which among the following encoding system can represent 65536 characters?a) ASCII b) EBCDIC c) Both a and b d)
None of these
424. From the ones given below, choose the correct arrangement of operators in order of higher precedence to lower
precedence.
1. && 2. % 3. >= 4. ++ a) 4,3,2,1 b) 2,3,1,4 c) 4,2,3,1 d) 4,1,2,3
425. If int y = 10, then find int z = (++y * (y++ + 5 )); a) 180 b) 176 c) 166 d) 170
426. Which of these is OOP’s principle?a) Early binding b) Dynamic binding c) Data hiding d) Polymorphism
427. Which of these is not a punctuator?a) : (colon) b) ; (semi-colon) c) . (dot) d) , (comma)
428. Select the valid range for the following java statement:-System.out.println((int)(Math.random()*15)+40); a) 15 to
40 b) 40 to 54 c) 1 to 15 d) 0 to 40
429. Break keyword is used to exit forcefully from:-a) loop b) switch c) both a and b d) none of these
430. The term ____________is used to describe a group of objects that have some common attributes and
behaviour. a) polymorphism b) abstraction c) inheritance d) class
431. When primitive data type is converted to its corresponding object of its class, it is called as _________.a) Boxing b)
Explicit type conversion c) Implicit type conversion d) Unboxing
432. The first line of a method which contains the access specifier, return type, method name and a list of parameters is
termed as_____________.(a) method signature b) method prototype or method header c) formal parameter d) actual
parameter)
433. State the value of y after the following is executed: char x=’A’; char y=Character.toLowerCase(x); a) false b) true c) a
d) 65
434. The logical operator which is a unary operator:a) && b) || c) ! d) >>
435. The function of Scanner class is available under ___________package. a) java.io b) java.util c) java.net d) java.lang
436. Math.pow(625,1/2) + Math.sqrt(121); a) 12 b) 12.0 c) 13.0 d) 11.0
437. The access modifier that gives most accessibility is:a) private b) public c) protected d) package
438. Choose the correct option if the following if statement is written with ternary operator:
if(n%2= =0) System.out.println(“Even”);
else System.out.println(“Odd”); a) String s= (n%2= =0) ? “Even” : “Odd”; b) System.out.println(n%2= =0 ? “Even” :
“Odd”); c) boolean b= (n%2= =0) ? “Even” : “Odd”; d) none of the above
439. Multiple branching statement of Java is:a) for b) while c) do while d) if else if ladder
440. Number of bits occupied by a short data type is:a) 8 bits b) 16 bits c) 32 bits d) 64 bits
441. Give the output of the following code:
String A=”26.0”, B=”74.0”; double C=Double.parseDouble(A); double D=Double.parseDouble(B);
System.out.println((C+D)); a) 26.074.0 b) 74 c) 100.0 d) 2674
442. Which one of the following is an exit controlled loop? a) while b) for c) do while d) repeat
443. How many times the inner loop is executed?
for(int i=1;i<=2;i++)
{
for(int j= -1;j<=2;j++)
{
System.out.print(j);
}
System.out.println();
}a) 4 times b) 8 times c) 12 times d) 16 times
444. The parameters described in the method header which receive the values from its caller method are called
_____________.a) formal parameter b) actual parameter c) original parameter d) none of the above
445. Consider the following code and state which one is correct statement about the following code.
abc p = new abc(5,7,9); a) method calling with actual parameter b) method declaration with formal parameter c)
invocation of parameterized constructor d) declaration of non-parameterized constructor
446. Wrapper classes are available in ___________package.a) java.io b) java.util c) java.lang d) java.awt
447. char c=65; What is value of ‘c’? a) a b) A c) ‘65’ d) “65”
448. The output of the method “DETERMINATION”.substring (2,6) is:-a) “TERM” b)”term” c) “Term” d) “TERMI”
449. The array int x[10] occupies:-a) 10 bytes b) 40 bytes c) 20 bytes d) 8 bytes
450.Which of the following is not a Java reserved word?(a) private (b) public (c) break (d) total
451. Who developed Java?(a) James Gosling (b) Robert James (c) Bjarne Stroustrup (d) Charles Babbage
452. Which of the following is a blue print that creates objects of similar types?(a) Abstraction (b) Encapsulation (c) class
(d) function
453. The process by which a class acquires the properties from another class is called:(a) polymorphism (b) inheritance
(c) bstraction (d) object
454. Which of the following keywords is used to create an instance of a class?((a) new (b) public (c) class (d) main)
455. Which of the following is non-numeric data type?((a) boolean (b) int (c) float (d) double)
456. Which of the following method will accept a string by using scanner object?((a) next( ) (b) next.read( ) (c)
next.String( ) (d) next.char( ))
457. Which of the following is the right way to use a comment in Java program?((a) /* comment */ (b) /* comment (c) //
comment // (d) */ comment */)
458. Which of the following is not a part of the looping construct?((a) close (b) for (c) break (d) continue)
459. Which of the following keywords can be used to terminate a switch case as well as a
loop construct? ((a) continue (b) void (c) break (d) stop)
460. Given: x + = x++ + ++x + --x Find the value, when x=5.((a) 21 (b) 22 (c) 23 (d) 24)
461. _____________ is a collection of classes.((a) Package (b) Object (c) variable (d) data type)
462. Wrapper class uses first letter in ____________ case.((a) sentence (b) lower (c) upper (d) toggle)
463. Cell numbers of a dimensional array are also known as:-(a) packets (b) blocks (c) subscripts (d) compartments
464. int y[ ] = {2,4,6,8}; System.out.print(y[1] +” “ + y[2]); (a) 2 8 (b) 6 8 (c) 2 4 (d) 4 6
465. ____________ method is used to join two strings.(a) trim( ) (b) concat( ) (c) replace( ) (d) charAt( )
466. The return type of the statement equals( ) is ____________.(a) float (b) String (c) int (d) boolean
467. A function can return only __________ value to its caller program.(a) one (b) two (c) three (d) four
468. If a function does not return any value its return type is _____________.(a) errors (b) static (c) void (d) None
469. A function may be associated with:-(a) return (b) call (c) promote (d) none
470. Assertion (A): int [] t={15,23,61,46}; a[4] returns 46. Reason (R): If we try to access an element outside the range of
index position 0 to n-1,it results to ArrayIndexOutofBoundsException. (a) Both Assertion (A) and Reason (R) are true and
Reason (R) is a correct explanation of Assertion (A). (b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a
correct explanation of Assertion (A). (c) Assertion (A) is true and Reason (R) is false. (d) Assertion (A) is false and Reason
(R) is true.
471. Assertion (A): In Java, an array containing 5 letters will require 10 bytes for storage Reason (R): The size of a
character data type is 2 bytes in Java. (a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
explanation of Assertion (A). (b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of
Assertion (A). (c) Assertion (A) is true and Reason (R) is false. (d) Assertion (A) is false and Reason (R) is true.
472. Assertion (A): Linear Search can be applied even if the array is not sorted. Reason (R): In linear search the search
operation begins from first element and goes till the last element. (a) Both Assertion (A) and Reason (R) are true and
Reason (R) is a correct explanation of Assertion (A). (b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a
correct explanation of Assertion (A). (c) Assertion (A) is true and Reason (R) is false. (d) Assertion (A) is false and Reason
(R) is true.
473. Assertion (A): Binary search is faster than linear search. Reason (R): Binary search takes place on sorted array. (a)
Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A). (b) Both Assertion (A)
and Reason (R) are true and Reason (R) is not a correct explanation of Assertion (A). (c) Assertion (A) is true and Reason
(R) is false. (d) Assertion (A) is false and Reason (R) is true.
474. Assertion (A): int n[]={2,3,4,5,6};n[1]+n[2]==n[3] will return true. Reason (R): The elements of an array are accessed
by the subscript. (a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A).
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion (A). (c) Assertion
(A) is true and Reason (R) is false. (d) Assertion (A) is false and Reason (R) is true.
475. Assertion (A): A String is a sequence of characters. Reason (R): Java provides a String class in the java. Lang package,
and objects of this class can be treated as variables of type String. (a) Both Assertion (A) and Reason (R) are true and
Reason (R) is a correct explanation of Assertion (A). (b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a
correct explanation of Assertion (A). (c) Assertion (A) is true and Reason (R) is false. (d) Assertion (A) is false and Reason
(R) is true.
476. Assertion (A): String n=”HARSHIT”; n.charAt(3) returns S. Reason (R): The charAt() method returns the character
present at the specified index position in the String. (a) Both Assertion (A) and Reason (R) are true and Reason (R) is a
correct explanation of Assertion (A). (b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct
explanation of Assertion (A). (c) Assertion (A) is true and Reason (R) is false. (d) Assertion (A) is false and Reason (R) is
true.
477.Assertion (A): equals() and compareTo() methods perform the same task. Reason (R): equals has a return type of
boolean and compareTo() returns integer data type. (a) Both Assertion (A) and Reason (R) are true and Reason (R) is a
correct explanation of Assertion (A). (b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct
explanation of Assertion (A). (c) Assertion (A) is true and Reason (R) is false. (d) Assertion (A) is false and Reason (R) is
true.
478. Assertion (A): “HAPPY BIRTHDAY”.endsWith(“DAY”); returns false. Reason (R): The return type of endsWith()
method is boolean. (a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion
(A). (b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion (A). (c)
Assertion (A) is true and Reason (R) is false. (d) Assertion (A) is false and Reason (R) is true.
479. Assertion (A): “COFFEE”.replace(‘F,E’) returns COEEEE Reason (R): The replace(char,char) function replaces all
occurrences of specified character in the string with the replacement character. (a) Both Assertion (A) and Reason (R)
are true and Reason (R) is a correct explanation of Assertion (A). (b) Both Assertion (A) and Reason (R) are true and
Reason (R) is not a correct explanation of Assertion (A). (c) Assertion (A) is true and Reason (R) is false. (d) Assertion (A) is
false and reason is true.
480. The code that operates on the data of an object is termed as:(a) Member function (b) Class (c) Object program (d)
Message
481. Which of the following is not a token ?(a) Keyword (b) Identifier (c) Procedure (d) Operator
482. Which operator among the following is unary ?(a) ! (b) ++ (c) -- (d) All of these
483. The hexadecimal integer – 0x12 is equivalent to the decimal number:(a) – 12 (b) – 18 (c) – 13 (d) – 16
484. *= is an example of _____ operator:(a) logical (b) ternary (c) shorthand (d) assignment
485. What will be the result produced by the following statement ?Math.ceil(-8.4) + Math.pow(2,-2);
(a) -8.0 (b) -9.45 (c) -7.75 (d) -8.25
486. Identify the error: System.out.println(max(4, 5));(a) Syntax (b) Logical (c) Runtime (d) No error
487. Name the package that contains ‘Integer’ class.(a) java.lang (b) java.awt (c) java.io (d) java.applet
488. Which of the following is an invalid literal ?1. “763” 2. 25D 3. ‘LION’ 4. ‘\0’ (a) 1 and 2 (b) Only 2 (c) Only 3 (d) 3 and
4
489. Which of the following methods extracts a part of the original string?(a) parseString() (b) getString() (c) substring()
(d) extString()
490. The number of bytes occupied by an array of int type with 7 elements is:(a) 56 (b) 7 (c) 14 (d) 28
491. Which of the following is not a jump statement ?(a) return (b) continue (c) break (d) None of these
492. Predict the output:System.out.println("MONARCH".substring(4).charAt(0));(a) A (b) R (c) C (d) M
493. Assertion (A): When an array is initialised, its size is not specified.
Reason (R): The size of an array is equal to the number of elements in the list.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation
of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of
Assertion (A)
(c) Assertion (A) is false and Reason (R) is true
(d) Assertion (A) is true and Reason (R) is false
494. Go through the following text and choose the correct answer:
Non-parameterized constructor does not have any parameter list i.e. accepts no parameter. It is also
known as default constructor. A default constructor may be either implicit or explicit. Java automatically
defines an implicit constructor. It initialises the data members with their default initial value.
A default constructor can be defined by:
(a) Java system only (b) programmers only (c) Both a and b (d) Specific packages
(xvii) Assertion (A): All relational operators are binary in nature.
Reason (R): Logical Not (!) operates on only one boolean value.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of
Assertion(A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
495. An object that is created by explicit call to a constructor and preceded with the ‘new’ command is
termed as ______ object:(a) Anonymous (b) Temporary (c) Explicit (d) Both a and b
496. int a[ ] = {2,3,4,5,6}, then a[ ].length will result in:(a) 6 (b) 5 (c) a[5] (d) Syntax error
497. char ch[ ] = {'A', 'B', 'C', 'D'};System.out.println (ch[1] + ch[3]);
What will be the output of the above code snippet ?(a) 133 (b) 134 (c) 135 (d) 136
498.Which of the following functions is used to remove leading and trailing white spaces from the string?
(trail(),trim(),slice(),truncate())
499.System.out.println(Integer.parseInt(“25”)+25);(2525,25,50,error)
500.The test used to check if character ch is lowercase.
(if(ch.isLowerCase()==true),if(IsLowerCase()==ch),if(Character.isLowerCase(ch)==true),none)