MCQOPTIONS
Saved Bookmarks
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 frame consists of: |
| A. | MAC address |
| B. | IP address |
| C. | both (a) and (b) |
| D. | none of the mentioned |
| Answer» B. IP address | |
| 408. |
What are the main methods of Java Regex? |
| A. | matches |
| B. | lookingAt |
| C. | find |
| D. | All of the above |
| Answer» E. | |
| 409. |
Which of the following statements about the regex API are 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 does public int start() 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 set of all strings over Sigma = {a,b} in which all strings having bbbb as substring 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 expressions are used to represent which language |
| A. | Recursive language |
| B. | Context free language |
| C. | Regular language |
| D. | All of these |
| Answer» D. All of these | |
| 413. |
Which of the following is not a class of java.util.regex? |
| A. | Pattern class |
| B. | matcher class |
| C. | PatternSyntaxException |
| D. | Regex class |
| Answer» E. | |
| 414. |
Which of the following identity is wrong? |
| A. | R + R = R |
| B. | R*)* = R* |
| C. | Both A and B |
| D. | (phi)R = R(phi) = RR* |
| Answer» E. | |
| 415. |
What does public int end(int group) 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 capturing group can represent the entire expression? |
| A. | group * |
| B. | group 0 |
| C. | group * or group 0 |
| D. | None of the mentioned |
| Answer» C. group * or group 0 | |
| 417. |
What is the significance of Matcher class for regular expression in 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 of these instances cannot be created? |
| A. | Integer Instance |
| B. | Generic Class Instance |
| C. | Generic Type Instance |
| D. | Collection Instances |
| Answer» D. Collection Instances | |
| 419. |
Which of these types cannot be used to initiate a generic type? |
| A. | Integer class |
| B. | Float Class |
| C. | Primitive Types |
| D. | Collections |
| Answer» D. Collections | |
| 420. |
What is the default value of byte variable? |
| A. | 0 |
| B. | 0.5 |
| C. | nul |
| D. | undefined |
| Answer» B. 0.5 | |
| 421. |
Which of the following reference types cannot be generic? |
| A. | Anonymous inner class |
| B. | Interface |
| C. | Inner class |
| D. | All of the mentioned |
| Answer» B. Interface | |
| 422. |
Which of the following is Faster, StringBuilder or StringBuffer? |
| A. | StringBuilder |
| B. | StringBuffer |
| C. | Both of the above |
| D. | None of the above |
| Answer» B. StringBuffer | |
| 423. |
Why are generics 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 of the following allows us to call generic methods as a normal method? |
| A. | Type Interface |
| B. | Interface |
| C. | Inner class |
| D. | All of the mentioned |
| Answer» B. Interface | |
| 425. |
Which of the following is incorrect statement regarding the use of generics and parameterized types in 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 of these type parameters is used for a generic class to return and accept a number? |
| A. | K |
| B. | N |
| C. | T |
| D. | V |
| Answer» C. T | |
| 427. |
Functional interfaces can be annotated as |
| A. | Function |
| B. | FunctionalInterface |
| C. | Functional |
| D. | Interface |
| Answer» C. Functional | |
| 428. |
Given a class named student, which of the following is a valid constructor declaration for the class? |
| A. | Student (student s) { } |
| B. | Student student ( ) { } |
| C. | Private final student ( ) { } |
| D. | Void student ( ) { } |
| Answer» B. Student student ( ) { } | |
| 429. |
Which of the following are not valid lambda expressions? |
| A. | () -> {} |
| B. | () -> “Raoul” |
| C. | () -> {return “Mario”;} |
| D. | (Integer i) -> return “Alan” + i; |
| Answer» E. | |
| 430. |
Which of these does Stream map() operates on |
| A. | Class |
| B. | Interface |
| C. | Predicate |
| D. | Function |
| Answer» E. | |
| 431. |
A functional interface acts as target types for which of the following? |
| A. | Lambda expression |
| B. | Method reference |
| C. | Constructor reference |
| D. | All of the above |
| Answer» E. | |
| 432. |
Which statement is true regarding an 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 is the return type of lambda expression? |
| A. | String |
| B. | Object |
| C. | void |
| D. | Function |
| Answer» E. | |
| 434. |
If a variable is declared final, it must include …………………. value. |
| A. | integer |
| B. | no |
| C. | initial |
| D. | float |
| Answer» D. float | |
| 435. |
Which is aggregate operation in Java 8 |
| A. | filter |
| B. | map |
| C. | forEach |
| D. | All |
| Answer» B. map | |
| 436. |
Example of functional interfaces |
| A. | java.util.concurrent.Callable |
| B. | java.lang.Runnable |
| C. | All |
| D. | None |
| Answer» D. None | |
| 437. |
Using which keyword we can access a value of the instance variables and class variables of that class inside the method of that class itself. |
| A. | Super |
| B. | Final |
| C. | This |
| D. | Either super or this |
| Answer» D. Either super or this | |
| 438. |
Which of the following does not belong: If a class inherits from some other class, it 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 space has been replaced with which of these in Java 8 |
| A. | PermSpace |
| B. | PermSpaceGen |
| C. | Metaspace |
| D. | MetaGenSpace |
| Answer» D. MetaGenSpace | |
| 440. |
How many methods are there in a functional interface in Java 8? |
| A. | 0 |
| B. | 1 |
| C. | 2 |
| D. | 3 |
| Answer» C. 2 | |
| 441. |
What is the Optional object used 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 of the following gets introduced with Java 8? |
| A. | Lambda expression |
| B. | Compact profiles |
| C. | Stream API |
| D. | Only first two |
| Answer» B. Compact profiles | |
| 443. |
A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such 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 Java 8 Interfaces, methods can be: |
| A. | default |
| B. | abstract |
| C. | all |
| D. | None |
| Answer» D. None | |
| 445. |
The newly introduced Streams API is available in which package of java 8: |
| A. | java.io.streams |
| B. | java.io.stream |
| C. | java.util.streams |
| D. | java.util.stream |
| Answer» E. | |
| 446. |
A pipeline is a sequence of what operations in java 8 |
| A. | multi-threading |
| B. | concurrent |
| C. | consequent |
| D. | stream |
| Answer» E. | |
| 447. |
What does SAM stand for in context of Functional Interface? |
| A. | Single Ambivalue Method |
| B. | Single Abstract Method |
| C. | Simple Active Markup |
| D. | Simple Abstract Markup |
| Answer» C. Simple Active Markup | |
| 448. |
Code for Java 8 essentially used to be |
| A. | Declarative |
| B. | Imperative |
| C. | Subjective |
| D. | None |
| Answer» C. Subjective | |
| 449. |
Nashorn the new JavaScript engine is an implementation of |
| A. | javax.engine.Engine |
| B. | javax.script.Engine |
| C. | javax.javaScript.Engine |
| D. | javax.script.ScriptEngine |
| Answer» E. | |
| 450. |
Which of the following functional interface represents a function that accepts a double-valued argument and produces a long-valued result? |
| A. | DoubleToLongFunction |
| B. | DoubleUnaryOperator |
| C. | Function |
| D. | IntBinaryOperator |
| Answer» B. DoubleUnaryOperator | |