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.

401.

Which statement is true given the following?Double d = Math.random();

A. 0.0 < d <= 1.0
B. 0.0 <= d < 1.0
C. Compilation fail
D. Cannot say.
Answer» C. Compilation fail
402.

Which two statements are true about wrapper or String classes?1. If x and y refer to instances of different wrapper classes, then the fragment x.equals(y) will cause a compiler failure.2. If x and y refer to instances of different wrapper classes, then x == y can sometimes be true.3. If x and y are String references and if x.equals(y) is true, then x == y is true.4. If x, y, and z refer to instances of wrapper classes and x.equals(y) is true, and y.equals(z) is true, then z.equals(x) will always be true.5. If x and y are String references and x == y is true, then y.equals(x) will be true.

A. 1 and 2
B. 2 and 3
C. 3 and 4
D. 4 and 5
Answer» E.
403.

Which of these class have only one field "TYPE"?

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

Standard output variable "out" is defined in which class?

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

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
406.

What is the output of this program?Note: inputoutput.java is stored in the disk.

A. true
B. false
C. prints number of bytes in file
D. prints number of characters in the file
Answer» D. prints number of characters in the file
407.

Ethernet&nbsp;frame&nbsp;consists&nbsp;of:

A. MAC address
B. IP address
C. both (a) and (b)
D. none of the mentioned
Answer» B. IP address
408.

What&nbsp;are&nbsp;the&nbsp;main&nbsp;methods&nbsp;of&nbsp;Java&nbsp;Regex?

A. matches
B. lookingAt
C. find
D. All of the above
Answer» E.
409.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;statements&nbsp;about&nbsp;the&nbsp;regex&nbsp;API&nbsp;are&nbsp;true?

A. Instances of the Pattern class are used to match character sequences against a given pattern
B. The package java.util.regex includes an exception called PatternSyntaxException
C. Instances of Matcher class are used to represent regular expressions in the form of String type
D. None of the above
Answer» C. Instances of Matcher class are used to represent regular expressions in the form of String type
410.

What&nbsp;does&nbsp;public&nbsp;int&nbsp;start()&nbsp;return?

A. returns start index of the input string
B. returns start index of the current match
C. returns start index of the previous match
D. none of the mentioned
Answer» D. none of the mentioned
411.

The&nbsp;set&nbsp;of&nbsp;all&nbsp;strings&nbsp;over&nbsp;Sigma&nbsp;=&nbsp;{a,b}&nbsp;in&nbsp;which&nbsp;all&nbsp;strings&nbsp;having&nbsp;bbbb&nbsp;as&nbsp;substring&nbsp;is

A. (a+b)* bbbb (a+b)*
B. (a+b)* bb (a+b)*bb
C. bbbb (a+b)*
D. bb (a+b)*
Answer» B. (a+b)* bb (a+b)*bb
412.

Regular&nbsp;expressions&nbsp;are&nbsp;used&nbsp;to&nbsp;represent&nbsp;which&nbsp;language

A. Recursive language
B. Context free language
C. Regular language
D. All of these
Answer» D. All of these
413.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;is&nbsp;not&nbsp;a&nbsp;class&nbsp;of&nbsp;java.util.regex?

A. Pattern class
B. matcher class
C. PatternSyntaxException
D. Regex class
Answer» E.
414.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;identity&nbsp;is&nbsp;wrong?

A. R + R = R
B. R*)* = R*
C. Both A and B
D. (phi)R = R(phi) = RR*
Answer» E.
415.

What&nbsp;does&nbsp;public&nbsp;int&nbsp;end(int&nbsp;group)&nbsp;return?

A. offset from last character of the subsequent group
B. offset from first character of the subsequent group
C. offset from last character matched
D. offset from first character matched
Answer» B. offset from first character of the subsequent group
416.

Which&nbsp;capturing&nbsp;group&nbsp;can&nbsp;represent&nbsp;the&nbsp;entire&nbsp;expression?

A. group *
B. group 0
C. group * or group 0
D. None of the mentioned
Answer» C. group * or group 0
417.

What&nbsp;is&nbsp;the&nbsp;significance&nbsp;of&nbsp;Matcher&nbsp;class&nbsp;for&nbsp;regular&nbsp;expression&nbsp;in&nbsp;java?

A. interpretes pattern in the string
B. Performs match in the string
C. interpretest both pattern and performs match operations in the string
D. None of the mentioned
Answer» D. None of the mentioned
418.

Which&nbsp;of&nbsp;these&nbsp;instances&nbsp;cannot&nbsp;be&nbsp;created?

A. Integer Instance
B. Generic Class Instance
C. Generic Type Instance
D. Collection Instances
Answer» D. Collection Instances
419.

Which&nbsp;of&nbsp;these&nbsp;types&nbsp;cannot&nbsp;be&nbsp;used&nbsp;to&nbsp;initiate&nbsp;a&nbsp;generic&nbsp;type?

A. Integer class
B. Float Class
C. Primitive Types
D. Collections
Answer» D. Collections
420.

What&nbsp;is&nbsp;the&nbsp;default&nbsp;value&nbsp;of&nbsp;byte&nbsp;variable?

A. 0
B. 0.5
C. nul
D. undefined
Answer» B. 0.5
421.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;reference&nbsp;types&nbsp;cannot&nbsp;be&nbsp;generic?

A. Anonymous inner class
B. Interface
C. Inner class
D. All of the mentioned
Answer» B. Interface
422.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;is&nbsp;Faster,&nbsp;StringBuilder&nbsp;or&nbsp;StringBuffer?

A. StringBuilder
B. StringBuffer
C. Both of the above
D. None of the above
Answer» B. StringBuffer
423.

Why&nbsp;are&nbsp;generics&nbsp;used?

A. Generics make code more fast
B. Generics make code more optimised and readable
C. Generics add stability to your code by making more of your bugs detectable at compile time
D. Generics add stability to your code by making more of your bugs detectable at a runtime
Answer» D. Generics add stability to your code by making more of your bugs detectable at a runtime
424.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;allows&nbsp;us&nbsp;to&nbsp;call&nbsp;generic&nbsp;methods&nbsp;as&nbsp;a&nbsp;normal&nbsp;method?

A. Type Interface
B. Interface
C. Inner class
D. All of the mentioned
Answer» B. Interface
425.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;is&nbsp;incorrect&nbsp;statement&nbsp;regarding&nbsp;the&nbsp;use&nbsp;of&nbsp;generics&nbsp;and&nbsp;parameterized&nbsp;types&nbsp;in&nbsp;Java?

A. Generics provide type safety by shifting more type checking responsibilities to the compiler
B. Generics and parameterized types eliminate the need for down casts when using Java Collections
C. When designing your own collections class (say, a linked list), generics and parameterized types allow you to achieve type safety with just a single class definition as opposed to defining multiple classes
D. All of the mentioned
Answer» D. All of the mentioned
426.

Which&nbsp;of&nbsp;these&nbsp;type&nbsp;parameters&nbsp;is&nbsp;used&nbsp;for&nbsp;a&nbsp;generic&nbsp;class&nbsp;to&nbsp;return&nbsp;and&nbsp;accept&nbsp;a&nbsp;number?

A. K
B. N
C. T
D. V
Answer» C. T
427.

Functional&nbsp;interfaces&nbsp;can&nbsp;be&nbsp;annotated&nbsp;as

A. Function
B. FunctionalInterface
C. Functional
D. Interface
Answer» C. Functional
428.

Given&nbsp;a&nbsp;class&nbsp;named&nbsp;student,&nbsp;which&nbsp;of&nbsp;the&nbsp;following&nbsp;is&nbsp;a&nbsp;valid&nbsp;constructor&nbsp;declaration&nbsp;for&nbsp;the&nbsp;class?

A. Student (student s) { }
B. Student student ( ) { }
C. Private final student ( ) { }
D. Void student ( ) { }
Answer» B. Student student ( ) { }
429.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;are&nbsp;not&nbsp;valid&nbsp;lambda&nbsp;expressions?

A. () -> {}
B. () -> “Raoul”
C. () -> {return “Mario”;}
D. (Integer i) -> return “Alan” + i;
Answer» E.
430.

Which&nbsp;of&nbsp;these&nbsp;does&nbsp;Stream&nbsp;map()&nbsp;operates&nbsp;on

A. Class
B. Interface
C. Predicate
D. Function
Answer» E.
431.

A&nbsp;functional&nbsp;interface&nbsp;acts&nbsp;as&nbsp;target&nbsp;types&nbsp;for&nbsp;which&nbsp;of&nbsp;the&nbsp;following?

A. Lambda expression
B. Method reference
C. Constructor reference
D. All of the above
Answer» E.
432.

Which&nbsp;statement&nbsp;is&nbsp;true&nbsp;regarding&nbsp;an&nbsp;object?

A. An object is what classes instantiated are from
B. An object is an instance of a class
C. An object is a variable
D. An object is a reference to an attribute
Answer» C. An object is a variable
433.

What&nbsp;is&nbsp;the&nbsp;return&nbsp;type&nbsp;of&nbsp;lambda&nbsp;expression?

A. String
B. Object
C. void
D. Function
Answer» E.
434.

&nbsp;If&nbsp;a&nbsp;variable&nbsp;is&nbsp;declared&nbsp;final,&nbsp;it&nbsp;must&nbsp;include&nbsp;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;.&nbsp;value.

A. integer
B. no
C. initial
D. float
Answer» D. float
435.

Which&nbsp;is&nbsp;aggregate&nbsp;operation&nbsp;in&nbsp;Java&nbsp;8

A. filter
B. map
C. forEach
D. All
Answer» B. map
436.

Example&nbsp;of&nbsp;functional&nbsp;interfaces

A. java.util.concurrent.Callable
B. java.lang.Runnable
C. All
D. None
Answer» D. None
437.

Using&nbsp;which&nbsp;keyword&nbsp;we&nbsp;can&nbsp;access&nbsp;a&nbsp;value&nbsp;of&nbsp;the&nbsp;instance&nbsp;variables&nbsp;and&nbsp;class&nbsp;variables&nbsp;of&nbsp;that&nbsp;class&nbsp;inside&nbsp;the&nbsp;method&nbsp;of&nbsp;that&nbsp;class&nbsp;itself.

A. Super
B. Final
C. This
D. Either super or this
Answer» D. Either super or this
438.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;does&nbsp;not&nbsp;belong:&nbsp;If&nbsp;a&nbsp;class&nbsp;inherits&nbsp;from&nbsp;some&nbsp;other&nbsp;class,&nbsp;it&nbsp;should

A. Make use of the parent class’s capabilities
B. Over-ride or add the minimum to accomplish the derived class’ purpose
C. Over-ride all the methods of its parent class
D. Make sure the result “IS-A-KIND-OF” its base class
Answer» D. Make sure the result “IS-A-KIND-OF” its base class
439.

PermGen&nbsp;space&nbsp;has&nbsp;been&nbsp;replaced&nbsp;with&nbsp;which&nbsp;of&nbsp;these&nbsp;in&nbsp;Java&nbsp;8

A. PermSpace
B. PermSpaceGen
C. Metaspace
D. MetaGenSpace
Answer» D. MetaGenSpace
440.

How&nbsp;many&nbsp;methods&nbsp;are&nbsp;there&nbsp;in&nbsp;a&nbsp;functional&nbsp;interface&nbsp;in&nbsp;Java&nbsp;8?

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

What&nbsp;is&nbsp;the&nbsp;Optional&nbsp;object&nbsp;used&nbsp;for?

A. Optional is used for optional runtime argument
B. Optional is used for optional spring profile
C. Optional is used to represent null with absent value
D. Optional means its not mandatory for method to return object
Answer» D. Optional means its not mandatory for method to return object
442.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;gets&nbsp;introduced&nbsp;with&nbsp;Java&nbsp;8?

A. Lambda expression
B. Compact profiles
C. Stream API
D. Only first two
Answer» B. Compact profiles
443.

A&nbsp;method&nbsp;within&nbsp;a&nbsp;class&nbsp;is&nbsp;only&nbsp;accessible&nbsp;by&nbsp;classes&nbsp;that&nbsp;are&nbsp;defined&nbsp;within&nbsp;the&nbsp;same&nbsp;package&nbsp;as&nbsp;the&nbsp;class&nbsp;of&nbsp;the&nbsp;method.&nbsp;Which&nbsp;one&nbsp;of&nbsp;the&nbsp;following&nbsp;is&nbsp;used&nbsp;to&nbsp;enforce&nbsp;such&nbsp;restriction?

A. Declare the method with the keyword public
B. Declare the method with the keyword private
C. Declare the method with the keyword protected
D. Do not declare the method with any accessibility modifiers
Answer» E.
444.

In&nbsp;Java&nbsp;8&nbsp;Interfaces,&nbsp;methods&nbsp;can&nbsp;be:

A. default
B. abstract
C. all
D. None
Answer» D. None
445.

The&nbsp;newly&nbsp;introduced&nbsp;Streams&nbsp;API&nbsp;is&nbsp;available&nbsp;in&nbsp;which&nbsp;package&nbsp;of&nbsp;java&nbsp;8:

A. java.io.streams
B. java.io.stream
C. java.util.streams
D. java.util.stream
Answer» E.
446.

A&nbsp;pipeline&nbsp;is&nbsp;a&nbsp;sequence&nbsp;of&nbsp;what&nbsp;operations&nbsp;in&nbsp;java&nbsp;8

A. multi-threading
B. concurrent
C. consequent
D. stream
Answer» E.
447.

What&nbsp;does&nbsp;SAM&nbsp;stand&nbsp;for&nbsp;in&nbsp;context&nbsp;of&nbsp;Functional&nbsp;Interface?

A. Single Ambivalue Method
B. Single Abstract Method
C. Simple Active Markup
D. Simple Abstract Markup
Answer» C. Simple Active Markup
448.

Code&nbsp;for&nbsp;Java&nbsp;8&nbsp;essentially&nbsp;used&nbsp;to&nbsp;be

A. Declarative
B. Imperative
C. Subjective
D. None
Answer» C. Subjective
449.

Nashorn&nbsp;the&nbsp;new&nbsp;JavaScript&nbsp;engine&nbsp;is&nbsp;an&nbsp;implementation&nbsp;of

A. javax.engine.Engine
B. javax.script.Engine
C. javax.javaScript.Engine
D. javax.script.ScriptEngine
Answer» E.
450.

Which&nbsp;of&nbsp;the&nbsp;following&nbsp;functional&nbsp;interface&nbsp;represents&nbsp;a&nbsp;function&nbsp;that&nbsp;accepts&nbsp;a&nbsp;double-valued&nbsp;argument&nbsp;and&nbsp;produces&nbsp;a&nbsp;long-valued&nbsp;result?

A. DoubleToLongFunction
B. DoubleUnaryOperator
C. Function
D. IntBinaryOperator
Answer» B. DoubleUnaryOperator