Explore topic-wise MCQs in Technical Programming.

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

1051.

Default Serialization process cannot be overridden.

A. True
B. false
Answer» C.
1052.

If member does not implement serialization, which exception would be thrown?

A. RuntimeException
B. SerializableException
C. NotSerializableException
D. UnSerializedException
Answer» D. UnSerializedException
1053.

What type of members are not serialized?

A. Private
B. Protected
C. Static
D. Throwable
Answer» D. Throwable
1054.

How many methods Serializable has?

A. 1
B. 2
C. 3
D. 0
Answer» E.
1055.

What is deserialization?

A. Turning object in memory into stream of bytes
B. Turning stream of bytes into an object in memory
C. Turning object in memory into stream of bits
D. Turning stream of bits into an object in memory
Answer» C. Turning object in memory into stream of bits
1056.

No object is serializable

A. Turning object in memory into stream of bytes
B. Turning stream of bytes into an object in memory
C. Turning object in memory into stream of bits
D. Turning stream of bits into an object in memory
Answer» B. Turning stream of bytes into an object in memory
1057.

How an object can become serializable?

A. If class implements java.io.Serializable class
B. If class or any superclass implements java.io.Serializable interface
C. Any object is serializable
D. No object is serializable
Answer» C. Any object is serializable
1058.

What is the output of this 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 { float x; FileInputStream fis = new FileInputStream("serial"); ObjectInputStream ois = new ObjectInputStream(fis); x = ois.readInt(); ois.close(); System.out.println(x); } catch (Exception e) { System.out.print("deserialization"); System.exit(0); } } }

A. 3
B. 3.5
C. serialization
D. deserialization
Answer» C. serialization
1059.

What is the output of this program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdefgh"; int length = obj.length(); char c[] = new char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1 = new CharArrayReader(c); CharArrayReader input2 = new CharArrayReader(c, 1, 4); int i; int j; try { while ((i = input1.read()) == (j = input2.read())) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } }

A. abc
B. abcd
C. abcde
D. None of the mentioned
Answer» E.
1060.

What is the output of this program? import java.io.*; class serialization { public static void main(String[] args) { try { Myclass object1 = new Myclass("Hello", -7, 2.1e10); FileOutputStream fos = new FileOutputStream("serial"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(object1); oos.flush(); oos.close(); } catch(Exception e) { System.out.println("Serialization" + e); System.exit(0); } try { int x; FileInputStream fis = new FileInputStream("serial"); ObjectInputStream ois = new ObjectInputStream(fis); x = ois.readInt(); ois.close(); System.out.println(x); } catch (Exception e) { System.out.print("deserialization"); System.exit(0); } } } class Myclass implements Serializable { String s; int i; double d; Myclass(String s, int i, double d) { this.d = d; this.i = i; this.s = s; } }

A. -7
B. Hello
C. 2.1E10
D. deserialization
Answer» E.
1061.

What is the output of this program? import java.io.*; class serialization { public static void main(String[] args) { try { Myclass object1 = new Myclass("Hello", -7, 2.1e10); FileOutputStream fos = new FileOutputStream("serial"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(object1); oos.flush(); oos.close(); } catch(Exception e) { System.out.println("Serialization" + e); System.exit(0); } try { Myclass object2; FileInputStream fis = new FileInputStream("serial"); ObjectInputStream ois = new ObjectInputStream(fis); object2 = (Myclass)ois.readObject(); ois.close(); System.out.println(object2); } catch (Exception e) { System.out.print("deserialization" + e); System.exit(0); } } } class Myclass implements Serializable { String s; int i; double d; Myclass (String s, int i, double d) { this.d = d; this.i = i; this.s = s; } }

A. s=Hello; i=-7; d=2.1E10
B. Hello; -7; 2.1E10
C. s; i; 2.1E10
D. Serialization
Answer» B. Hello; -7; 2.1E10
1062.

Which of these is method of ObjectOutput interface used to write the object to input or output stream as required?

A. write()
B. Write()
C. StreamWrite()
D. writeObject()
Answer» E.
1063.

Which of these is a method of ObjectOutput interface used to finalize the output state so that any buffers are cleared?

A. clear()
B. flush()
C. fflush()
D. close()
Answer» C. fflush()
1064.

Which of these interface extends DataOutput interface?

A. Serializable
B. Externalization
C. ObjectOutput
D. ObjectInput
Answer» D. ObjectInput
1065.

Which of these is an interface for control over serialization and deserialization?

A. Serializable
B. Externalization
C. FileFilter
D. ObjectInput
Answer» C. FileFilter
1066.

Which of these process occur automatically by java runtime system?

A. Serialization
B. Garbage collection
C. File Filtering
D. All of the mentioned
Answer» B. Garbage collection
1067.

How to read a classpath file?

A. InputStream in =this.getClass().getResource(“SomeTextFile.txt”);
B. InputStream in =this.getClass().getResourceClasspath(“SomeTextFile.txt”);
C. InputStream in =this.getClass().getResourceAsStream(“SomeTextFile.txt”);
D. InputStream in =this.getClass().getResource(“classpath:/SomeTextFile.txt”);
Answer» D. InputStream in =this.getClass().getResource(“classpath:/SomeTextFile.txt”);
1068.

Which environment variable is used to set java path?

A. JAVA
B. JAVA_HOME
C. CLASSPATH
D. MAVEN_HOME
Answer» C. CLASSPATH
1069.

How to assign values to variable using property?

A. @Value(“${my.property}”) private String prop;
B. @Property(“${my.property}”) private String prop;
C. @Environment(“${my.property}”) private String prop;
D. @Env(“${my.property}”) private String prop;
Answer» B. @Property(“${my.property}”) private String prop;
1070.

How to use environment properties in the class?

A. @Environment
B. @Variable
C. @Property
D. @Autowired
Answer» E.
1071.

What is true about setProperties method?

A. setProperties method changes the set of Java Properties which are persistent
B. Changing the system properties within an application will affect future invocations
C. setProperties method changes the set of Java Properties which are not persistent
D. setProperties writes the values directly into the file which stores all the properties
Answer» D. setProperties writes the values directly into the file which stores all the properties
1072.

What does System.getProperty(“variable”) return?

A. compilation error
B. value stored in variable
C. runtime error
D. null
Answer» E.
1073.

Which system property stores installation directory of JRE?

A. user.home
B. java.class.path
C. java.class.path
D. user.dir
Answer» D. user.dir
1074.

Java system properties can be set at runtime.

A. True
B. false
Answer» B. false
1075.

Which of the following is true about Java system properties?

A. Java system properties are accessible by any process
B. Java system properties are accessible by processes they are added to
C. Java system properties are retrieved by System.getenv()
D. Java system prooerties are set by System.setenv()
Answer» C. Java system properties are retrieved by System.getenv()
1076.

Which object Java application uses to create a new process?

A. Process
B. Builder
C. ProcessBuilder
D. CreateBuilder
Answer» D. CreateBuilder
1077.

What is the output of this program? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"My Thread"); t.start(); } public void run() { System.out.println(t); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }

A. My Thread
B. Thread[My Thread,5,main].
C. Compilation Error
D. Runtime Error
Answer» C. Compilation Error
1078.

What is the output of this program? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"My Thread"); t.start(); } public void run() { System.out.println(t.getName()); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }

A. My Thread
B. Thread[My Thread,5,main].
C. Compilation Error
D. Runtime Error
Answer» B. Thread[My Thread,5,main].
1079.

What is the output of this program? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"My Thread"); t.start(); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }

A. My Thread
B. Thread[My Thread,5,main]
C. Compilation Error
D. Runtime Error
Answer» D. Runtime Error
1080.

What is the output of this program? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"New Thread"); t.start(); } public void run() { t.setPriority(Thread.MAX_PRIORITY); System.out.println(t); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }

A. Thread[New Thread,0,main].
B. Thread[New Thread,1,main].
C. Thread[New Thread,5,main].
D. Thread[New Thread,10,main].
Answer» E.
1081.

What is the output of this program? class newthread implements Runnable { Thread t1,t2; newthread() { t1 = new Thread(this,"Thread_1"); t2 = new Thread(this,"Thread_2"); t1.start(); t2.start(); } public void run() { t2.setPriority(Thread.MAX_PRIORITY); System.out.print(t1.equals(t2)); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }

A. true
B. false
C. truetrue
D. falsefalse
Answer» E.
1082.

Which of these method of Thread class is used to suspend a thread for a period of time?

A. sleep()
B. terminate()
C. suspend()
D. stop()
Answer» B. terminate()
1083.

Which of these interface is implemented by Thread class?

A. Runnable
B. Connections
C. set
D. MapConnections
Answer» B. Connections
1084.

Which of these class is used to make a thread?

A. String
B. System
C. Thread
D. Runnable
Answer» D. Runnable
1085.

Which of interface contains all the methods used for handling thread related operations in Java?

A. Runnable interface
B. Math interface
C. System interface
D. ThreadHandling interface
Answer» B. Math interface
1086.

What is the output of this program? class X { int a; double b; } class Y extends X { int c; } class Output { public static void main(String args[]) { X a = new X(); Y b = new Y(); Class obj; obj = b.getClass(); System.out.print(obj.getSuperclass()); } }

A. X
B. Y
C. class X
D. class Y
Answer» D. class Y
1087.

What is the output of this program? class X { int a; double b; } class Y extends X { int c; } class Output { public static void main(String args[]) { X a = new X(); Y b = new Y(); Class obj; obj = a.getClass(); System.out.print(obj.getName()); } }

A. X
B. Y
C. a
D. b
Answer» B. Y
1088.

Which of these methods returns the class of an object?

A. getClass()
B. Class()
C. WhoseClass()
D. WhoseObject()
Answer» B. Class()
1089.

Which of these classes encapsulate runtime state of an object?

A. Class
B. System
C. Runtime
D. Catche
Answer» B. System
1090.

What is the output of this program? class X { int a; double b; } class Y extends X { int c; } class Output { public static void main(String args[]) { X a = new X(); Y b = new Y(); Class obj; obj = b.getClass(); System.out.print(obj.isLocalClass()); } }

A. 0
B. 1
C. true
D. False
Answer» E.
1091.

What is the output of this program? class X { int a; double b; } class Y extends X { int c; } class Output { public static void main(String args[]) { X a = new X(); Y b = new Y(); Class obj; obj = b.getClass(); System.out.print(obj.isInstance(a)); } }

A. 0
B. 1
C. True
D. false
Answer» E.
1092.

What is the output of this program? class X { int a; double b; } class Y extends X { int c; } class Output { public static void main(String args[]) { X a = new X(); Y b = new Y(); Class obj; obj = b.getClass(); System.out.print(b.equals(a)); } }

A. 0
B. 1
C. true
D. False
Answer» E.
1093.

What is the output of this program? class X { int a; double b; } class Y extends X { int c; } class Output { public static void main(String args[]) { X a = new X(); Y b = new Y(); Class obj; obj = b.getClass(); System.out.print(obj.getSuperclass()); } }

A. X
B. Y
C. class X
D. class Y
Answer» D. class Y
1094.

Which of these Exceptions is thrown by loadClass() method of ClassLoader class?

A. IOException
B. SystemException
C. ClassFormatError
D. ClassNotFoundException
Answer» E.
1095.

Which of these methods return a class object given its name?

A. getClass()
B. findClass()
C. getSystemClass()
D. findSystemClass()
Answer» E.
1096.

Which of these class defines how the classes are loaded?

A. Class
B. System
C. Runtime
D. ClassLoader
Answer» E.
1097.

Which of these methods returns the total number of bytes of memory available to the program?

A. getMemory()
B. TotalMemory()
C. SystemMemory()
D. getProcessMemory()
Answer» C. SystemMemory()
1098.

Which of the following exceptions is thrown by every method of Runtime class?

A. IOException
B. SystemException
C. SecurityException
D. RuntimeException
Answer» D. RuntimeException
1099.

Which of these classes encapsulate runtime enviroment?

A. Class
B. System
C. Runtime
D. ClassLoader
Answer» D. ClassLoader
1100.

Will this program generate same output is executed again? class Output { public static void main(String args[]) { int y = double z = Math.random(); System.out.print(y); } }

A. Yes
B. No
C. Compiler Dependent
D. Operating System Dependent
Answer» C. Compiler Dependent