Explore topic-wise MCQs in Testing Subject.

This section includes 657 Mcqs, each offering curated multiple-choice questions to sharpen your Testing Subject knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of this program? import java.lang.System; class Output { public static void main(String args[]) { byte a[] = { 65, 66, 67, 68, 69, 70 }; byte b[] = { 71, 72, 73, 74, 75, 76 }; System.arraycopy(a, 0, b, 0, a.length); System.out.print(new String(a) + " " + new String(b)); } }

A. ABCDEF ABCDEF
B. ABCDEF GHIJKL
C. GHIJKL ABCDEF
D. GHIJKL GHIJKL
Answer» B. ABCDEF GHIJKL
2.

What is the output of this program? import java.lang.System; class Output { public static void main(String args[]) { long start, end; start = System.currentTimeMillis(); for (int i = 0; i < 10000000; i++); end = System.currentTimeMillis(); System.out.print(end - start); } }

A. 0
B. 1
C. 1000
D. System Dependent
Answer» E.
3.

Which of these values are returns under the case of normal termination of a program?

A. 0
B. 1
C. 2
D. 3
Answer» B. 1
4.

Which of these method can set the out stream to OutputStream?

A. setStream()
B. setosteam()
C. setOut()
D. streamtoOstream()
Answer» D. streamtoOstream()
5.

Which of these methods loads the specified dynamic library?

A. load()
B. library()
C. loadlib()
D. loadlibrary()
Answer» B. library()
6.

Which of these methods initiates garbage collection?

A. gc()
B. garbage()
C. garbagecollection()
D. Systemgarbagecollection()
Answer» B. garbage()
7.

Which of these exceptions is thrown by methods of System class?

A. IOException
B. SystemException
C. SecurityException
D. InputOutputException
Answer» D. InputOutputException
8.

What is the output of this program? class Output { public static void main(String args[]) { double x = 2.0; double y = 3.0; double z = Math.pow( x, y ); System.out.print(z); } }

A. 2.0
B. 4.0
C. 8.0
D. 9.0
Answer» D. 9.0
9.

What is the output of this program? class Output { public static void main(String args[]) { double x = 3.1; double y = 4.5; double z = Math.max( x, y ); System.out.print(z); } }

A. true
B. flase
C. 3.1
D. 4.5
Answer» E.
10.

What is the output of this program? class Output { public static void main(String args[]) { int x = 3.14; int y = (int) Math.abs(x); System.out.print(y); } }

A. 0
B. 3
C. 3.0
D. 3.1
Answer» C. 3.0
11.

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

A. 2
B. 3
C. 4
D. 2.5
Answer» C. 4
12.

Which of these class encapsulate the run time state of an object or an interface?

A. Class
B. Object
C. Runtime
D. System
Answer» B. Object
13.

Which of these class contains only floating point functions?

A. Math
B. Process
C. System
D. Object
Answer» B. Process
14.

Which of these method is a rounding function of Math class?

A. max()
B. min()
C. abs()
D. all of the mentioned
Answer» E.
15.

What is the value of double consonant ‘E’ defined in Math class?

A. approximately 3
B. approximately 3.14
C. approximately 2.72
D. approximately 0
Answer» D. approximately 0
16.

Which of these method of Object class can generate duplicate copy of the object on which it is called?

A. clone()
B. copy()
C. duplicate()
D. dito()
Answer» B. copy()
17.

Which of these class is superclass of all other classes?

A. Math
B. Process
C. System
D. Object
Answer» E.
18.

What is the output of this program? class Output { public static void main(String args[]) { byte a[] = { 65, 66, 67, 68, 69, 70 }; byte b[] = { 71, 72, 73, 74, 75, 76 }; System.arraycopy(a, 1, b, 3, 0); System.out.print(new String(a) + " " + new String(b)); } }

A. ABCDEF GHIJKL
B. ABCDEF GCDEFL
C. GHIJKL ABCDEF
D. GCDEFL GHIJKL
Answer» B. ABCDEF GCDEFL
19.

What is the output of this program? class Output { public static void main(String args[]) { byte a[] = { 65, 66, 67, 68, 69, 70 }; byte b[] = { 71, 72, 73, 74, 75, 76 }; System.arraycopy(a, 2, b, 1, a.length-2); System.out.print(new String(a) + " " + new String(b)); } }

A. ABCDEF GHIJKL
B. ABCDEF GCDEFL
C. GHIJKL ABCDEF
D. GCDEFL GHIJKL
Answer» C. GHIJKL ABCDEF
20.

What is the output of this program? class Output { public static void main(String args[]) { byte a[] = { 65, 66, 67, 68, 69, 70 }; byte b[] = { 71, 72, 73, 74, 75, 76 }; System.arraycopy(a , 0, b, 0, a.length); System.out.print(new String(a) + " " + new String(b)); } }

A. ABCDEF ABCDEF
B. ABCDEF GHIJKL
C. GHIJKL ABCDEF
D. GHIJKL GHIJKL
Answer» B. ABCDEF GHIJKL
21.

What is the output of this program? class Output { public static void main(String args[]) { long start, end; start = System.currentTimeMillis(); for (int i = 0; i < 10000000; i++); end = System.currentTimeMillis(); System.out.print(end - start); } }

A. 0
B. 1
C. 100
D. System Dependent
Answer» E.
22.

Which of these class holds a collection of static methods and variables?

A. Void
B. Process
C. Runtime
D. System
Answer» E.
23.

Which of the following is method of System class is used to find how long a program takes to execute?

A. currenttime()
B. currentTime()
C. currentTimeMillis()
D. currenttimeMillis()
Answer» D. currenttimeMillis()
24.

Which of these class can encapsulate an entire executing program?

A. Void
B. Process
C. Runtime
D. System
Answer» C. Runtime
25.

Standard output variable ‘out’ is defined in which class?

A. Void
B. Process
C. Runtime
D. System
Answer» E.
26.

Which of the following method of Process class can terminate a process?

A. void kill()
B. void destroy()
C. void terminate()
D. void exit()
Answer» C. void terminate()
27.

Which of these class have only one field ‘TYPE’?

A. Void
B. Process
C. System
D. Runtime
Answer» B. Process
28.

What is the output of this program? class Output { public static void main(String args[]) { Long i = new Long(256); System.out.print(i.hashCode()); } }

A. 256
B. 256.0
C. 256.00
D. 257.00
Answer» B. 256.0
29.

What is the output of this program? class Output { public static void main(String args[]) { Integer i = new Integer(257); float x = i.floatValue(); System.out.print(x); } }

A. 0
B. 1
C. 257
D. 257.0
Answer» E.
30.

What is the output of this program? class Output { public static void main(String args[]) { Integer i = new Integer(257); byte x = i.byteValue(); System.out.print(x); } }

A. 0
B. 1
C. 256
D. 257
Answer» C. 256
31.

What is the output of this program? class Output { public static void main(String args[]) { char a[] = {'a', '5', 'A', ' '}; System.out.print(Character.isDigit(a[0]) + " "); System.out.print(Character.isWhitespace(a[3]) + " "); System.out.print(Character.isUpperCase(a[2])); } }

A. true false true
B. false true true
C. true true false
D. false false false
Answer» C. true true false
32.

Which of these methods is used to obtain value of invoking object as a long?

A. long value()
B. long longValue()
C. Long longvalue()
D. Long Longvalue()
Answer» C. Long longvalue()
33.

Which of the following is method of wrapper Integer for converting the value of an object into int?

A. bytevalue()
B. int intValue();
C. Bytevalue()
D. Byte Bytevalue()
Answer» C. Bytevalue()
34.

Which of these is wrapper for simple data type char?

A. Float
B. Character
C. String
D. Integer
Answer» C. String
35.

Which of these is a super class of wrappers Long, Character & Integer?

A. Long
B. Digits
C. Float
D. Number
Answer» E.
36.

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

A. int hash()
B. int hashcode()
C. int hashCode()
D. Integer hashcode()
Answer» D. Integer hashcode()
37.

Which of these is a wrapper for data type int?

A. Integer
B. Long
C. Byte
D. Double
Answer» B. Long
38.

What is the output of this program? class binary { public static void main(String args[]) { int num = 17; System.out.print(Integer.toBinaryString(num)); } }

A. 1001c
B. 10011
C. 11011
D. 10001
Answer» E.
39.

What is the output of this program? class isNaN_output { public static void main(String args[]) { Double d = new Double(1 / 0.); boolean x = d.isNaN(); System.out.print(x); } }

A. 0
B. 1
C. True
D. False
Answer» E.
40.

What is the output of this program? class isinfinite_output { public static void main(String args[]) { Double d = new Double(1 / 0.); boolean x = d.isInfinite(); System.out.print(x); } }

A. 0
B. 1
C. True
D. False
Answer» D. False
41.

Which of the following package stores all the simple data types in java?

A. lang
B. java
C. util
D. java.packages
Answer» B. java
42.

Which of these methods is used to check for infinitely large and small values?

A. isInfinite()
B. isNaN()
C. Isinfinite()
D. IsNaN()
Answer» B. isNaN()
43.

Which of the following is method of wrapper Float for converting the value of an object into byte?

A. bytevalue()
B. byte byteValue()
C. Bytevalue()
D. Byte Bytevalue().
Answer» C. Bytevalue()
44.

Which of these is wrapper for simple data type float?

A. float
B. double
C. Float
D. Double
Answer» D. Double
45.

Which of these is a super class of wrappers Double & Integer?

A. Long
B. Digits
C. Float
D. Number
Answer» E.
46.

Which of these is a process of converting a simple data type into a class?

A. type wrapping
B. type conversion
C. type casting
D. none of the Mentioned.
Answer» B. type conversion
47.

Which of these classes is not included in java.lang?

A. Byte
B. Integer
C. Array
D. Class
Answer» D. Class
48.

What is the output of this program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.insert(1,"Java"); System.out.println(s1); } }

A. hello
B. Java
C. Hello Java
D. HelloJava
Answer» E.
49.

What is the output of this program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello World"); s1.insert(6 , "Good "); System.out.println(s1); } }

A. HelloGoodWorld
B. HellGoodoWorld
C. HellGood oWorld
D. Hello Good World
Answer» E.
50.

What is the output of this program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.setCharAt(1,'x'); System.out.println(s1); } }

A. xello
B. xxxxx
C. Hxllo
D. Hexlo
Answer» D. Hexlo