

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.
1601. |
What is the replacement of joda time library in java 8? |
A. | Java.time (JSR-310) |
B. | java.date (JSR-310) |
C. | java.joda |
D. | java.jodaTime |
Answer» B. java.date (JSR-310) | |
1602. |
How to identify if a timezone is eligible for DayLight Saving? |
A. | useDaylightTime() of Time class |
B. | useDaylightTime() of Date class |
C. | useDaylightTime() of TimeZone class |
D. | useDaylightTime() of DateTime class |
Answer» D. useDaylightTime() of DateTime class | |
1603. |
Is SimpleDateFormat thread safe? |
A. | True |
B. | False |
Answer» C. | |
1604. |
How to convert a String to a Date object? |
A. | SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); sdf.parse(new Date()); |
B. | SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); sdf.format(new Date()); |
C. | SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); new Date().parse(); |
D. | SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); new Date().format(); |
Answer» B. SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); sdf.format(new Date()); | |
1605. |
How to convert Date object to String? |
A. | SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); sdf.parse(new Date()); |
B. | SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); sdf.format(new Date()); |
C. | SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); new Date().parse(); |
D. | SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); new Date().format(); |
Answer» C. SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-mm-dd”); new Date().parse(); | |
1606. |
How to format date from one form to another? |
A. | SimpleDateFormat |
B. | DateFormat |
C. | SimpleFormat |
D. | DateConverter |
Answer» B. DateFormat | |
1607. |
public class AddDemo { public static void main(String args[]) { BigDecimal b = new BigDecimal("23.43"); BigDecimal br = new BigDecimal("24"); BigDecimal bres = b.add(new BigDecimal("450.23")); System.out.println("Add: "+bres); MathContext mc = new MathContext(2, RoundingMode.DOWN); BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc); System.out.println("Add using MathContext: "+bdecMath); } } |
A. | Compilation failure |
B. | Add: 684.66 Add using MathContext: 6.8E+2 |
C. | Runtime exception |
D. | Add 6.8E+2 Add using MathContext: 684.66 |
Answer» C. Runtime exception | |
1608. |
Which class is a library of functions to perform arithmetic operations of BigInteger and BigDecimal? |
A. | MathContext |
B. | MathLib |
C. | BigLib |
D. | BigContext |
Answer» B. MathLib | |
1609. |
What is BigDecimal.ONE? |
A. | wrong statement |
B. | custom defined statement |
C. | static variable with value 1 on scale 10 |
D. | static variable with value 1 on scale 0 |
Answer» E. | |
1610. |
BigDecimal is a part of which package? |
A. | java.lang |
B. | java.math |
C. | java.util |
D. | java.io |
Answer» C. java.util | |
1611. |
Which of the following is not provided by BigDecimal? |
A. | scale manipulation |
B. | + operator |
C. | rounding |
D. | hashing |
Answer» C. rounding | |
1612. |
What is the limitation of toString() method of BigDecimal? |
A. | There is no limitation |
B. | toString returns null |
C. | toString returns the number in expanded form |
D. | toString uses scientific notation |
Answer» E. | |
1613. |
What is the base of BigDecimal data type? |
A. | Base 2 |
B. | Base 8 |
C. | Base 10 |
D. | Base e |
Answer» D. Base e | |
1614. |
What is the output of below code snippet? double a = 0.02; double b = 0.03; double c = b - a; System.out.println(c); BigDecimal _a = new BigDecimal("0.02"); BigDecimal _b = new BigDecimal("0.03"); BigDecimal _c = b.subtract(_a); System.out.println(_c); |
A. | 0.009999999999999998 0.01 |
B. | 0.01 0.009999999999999998 |
C. | 0.01 0.01 |
D. | 0.009999999999999998 |
Answer» B. 0.01 0.009999999999999998 | |
1615. |
Which of the below data type doesn’t support overloaded methods for +,-,* and /? |
A. | int |
B. | float |
C. | double |
D. | BigDecimal |
Answer» E. | |
1616. |
Which of the following is the advantage of BigDecimal over double? |
A. | Syntax |
B. | Memory usage |
C. | Garbage creation |
D. | Precision |
Answer» E. | |
1617. |
Are enums are type-safe? |
A. | True |
B. | False |
Answer» B. False | |
1618. |
Which class does all the Enums extend? |
A. | Object |
B. | Enums |
C. | Enum |
D. | Enum Class |
Answer» D. Enum Class | |
1619. |
Which method returns the elements of Enum class? |
A. | getEnums() |
B. | getEnumConstants() |
C. | getEnumList() |
D. | getEnum() |
Answer» C. getEnumList() | |
1620. |
What is the output of below code snippet? enum Enums { A, B, C; private Enums() { System.out.println(10); } } public class MainClass { public static void main(String[] args) { Enum en = Enums.B; } } |
A. | 10 10 10 |
B. | Compilation Error |
C. | Runtime Exception |
D. | 10 10 |
Answer» B. Compilation Error | |
1621. |
What is the output of below code snippet? enum Levels { private TOP, public MEDIUM, protected BOTTOM; } |
A. | Runtime Error |
B. | EnumNotDefined Exception |
C. | It runs successfully |
D. | Compilation Error |
Answer» E. | |
1622. |
What is the output of below code snippet? class A { } enum Enums extends A { ABC, BCD, CDE, DEF; } |
A. | Runtime Error |
B. | Compilation Error |
C. | It runs successfully |
D. | EnumNotDefined Exception |
Answer» C. It runs successfully | |
1623. |
If we try to add Enum constants to a TreeSet, what sorting order will it use? |
A. | Sorted in the order of declaration of Enums |
B. | Sorted in alphabetical order of Enums |
C. | Sorted based on order() method |
D. | Sorted in descending order of names of Enums |
Answer» B. Sorted in alphabetical order of Enums | |
1624. |
enum Season { WINTER, SPRING, SUMMER, FALL }; System.out.println(Season.WINTER.ordinal()); |
A. | 0 |
B. | 1 |
C. | 2 |
D. | 3 |
Answer» B. 1 | |
1625. |
Can we create instance of Enum outside of Enum itself? |
A. | True |
B. | False |
Answer» C. | |
1626. |
What is the order of variables in Enum? |
A. | Ascending order |
B. | Descending order |
C. | Random order |
D. | depends on the order() method |
Answer» B. Descending order | |
1627. |
What is the output of this program? class asciicodes { public static void main(String args[]) { char var1 = 'A'; char var2 = 'a'; System.out.println((int)var1 + " " + (int)var2); } } |
A. | 162 |
B. | 65 97 |
C. | 67 95 |
D. | 66 98 |
Answer» C. 67 95 | |
1628. |
What is the output of this program? class booloperators { public static void main(String args[]) { boolean var1 = true; boolean var2 = false; System.out.println((var2 & var2)); } |
A. | 0 |
B. | 1 |
C. | True |
D. | False |
Answer» E. | |
1629. |
What is the output of this program? class mainclass { public static void main(String args[]) { boolean var1 = true; boolean var2 = false; if (var1) System.out.println(var1); else System.out.println(var2); } } |
A. | 0 |
B. | 1 |
C. | True |
D. | False |
Answer» D. False | |
1630. |
What is the output of this program? class mainclass { public static void main(String args[]) { char a = 'A'; a++; System.out.print((int)a); } } |
A. | 66 |
B. | 67 |
C. | 55 |
D. | 54 |
Answer» B. 67 | |
1631. |
What is the output of this program? class array_output { public static void main(String args[]) { char array_variable [] = new char[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = 'i'; System.out.print(array_variable[i] + "" ); i++; } } } |
A. | i i i i i |
B. | 0 1 2 3 4 |
C. | i j k l m |
D. | None of the mentioned |
Answer» B. 0 1 2 3 4 | |
1632. |
Which one is a valid declaration of a boolean? |
A. | boolean b1 = 1; |
B. | boolean b2 = ‘false’; |
C. | boolean b3 = false; |
D. | boolean b4 = ‘true’ |
Answer» D. boolean b4 = ‘true’ | |
1633. |
Which of these occupy first 0 to 127 in Unicode character set used for characters in Java? |
A. | ASCII |
B. | ISO-LATIN-1 |
C. | None of the mentioned |
D. | ASCII and ISO-LATIN1 |
Answer» E. | |
1634. |
Which of these values can a boolean variable contain? |
A. | True & False |
B. | 0 & 1 |
C. | Any integer value |
D. | true |
Answer» B. 0 & 1 | |
1635. |
Which of these coding types is used for data type characters in Java? |
A. | ASCII |
B. | ISO-LATIN-1 |
C. | UNICODE |
D. | None of the mentioned |
Answer» D. None of the mentioned | |
1636. |
What is the numerical range of a char data type in Java? |
A. | -128 to 127 |
B. | 0 to 256 |
C. | 0 to 32767 |
D. | 0 to 65535 |
Answer» E. | |
1637. |
What is the output of this program? class area { public static void main(String args[]) { double r, pi, a; r = 9.8; pi = 3.14; a = pi * r * r; System.out.println(a); } } |
A. | 301.5656 |
B. | 301 |
C. | 301.56 |
D. | 301.56560000 |
Answer» B. 301 | |
1638. |
What is the output of this program? class increment { public static void main(String args[]) { int g = 3; System.out.print(++g * 8); } } |
A. | 25 |
B. | 24 |
C. | 32 |
D. | 33 |
Answer» D. 33 | |
1639. |
What will be the output of these statement? class output { public static void main(String args[]) { double a, b,c; a = 3.0/0; b = 0/4.0; c=0/0.0; System.out.println(a); System.out.println(b); System.out.println(c); } } |
A. | Infinity |
B. | 0.0 |
C. | NaN |
D. | all of the mentioned |
Answer» E. | |
1640. |
What is the output of this program? class average { public static void main(String args[]) { double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5}; double result; result = 0; for (int i = 0; i < 6; ++i) result = result + num[i]; System.out.print(result/6); } } |
A. | 16.34 |
B. | 16.566666644 |
C. | 16.46666666666667 |
D. | 16.46666666666666 |
Answer» D. 16.46666666666666 | |
1641. |
Which data type value is returned by all transcendental math functions? |
A. | int |
B. | float |
C. | double |
D. | long |
Answer» D. long | |
1642. |
Which of these literals can be contained in float data type variable? |
A. | -1.7e+308 |
B. | -3.4e+038 |
C. | +1.7e+308 |
D. | -3.4e+050 |
Answer» C. +1.7e+308 | |
1643. |
An expression involving byte, int, and literal numbers is promoted to which of these? |
A. | int |
B. | long |
C. | byte |
D. | float |
Answer» B. long | |
1644. |
Which of the following are legal lines of Java code? 1. int w = (int)888.8; 2. byte x = (byte)100L; 3. long y = (byte)100; 4. byte z = (byte)100L; |
A. | 1 and 2 |
B. | 2 and 3 |
C. | 3 and 4 |
D. | All statements are correct. |
Answer» E. | |
1645. |
What is the range of byte data type in Java? |
A. | -128 to 127 |
B. | -32768 to 32767 |
C. | -2147483648 to 2147483647 |
D. | None of the mentioned |
Answer» B. -32768 to 32767 | |
1646. |
What is the range of short data type in Java? |
A. | -128 to 127 |
B. | -32768 to 32767 |
C. | -2147483648 to 2147483647 |
D. | None of the mentioned |
Answer» C. -2147483648 to 2147483647 | |
1647. |
A magnetic tape volume that is used on a data processing operation without any change to its contents is |
A. | Magnetic disk |
B. | Magnetic disk |
C. | Master tape |
D. | Card reader |
Answer» D. Card reader | |
1648. |
Which of these access specifiers can be used for an interface? |
A. | Public |
B. | Protected |
C. | Private |
D. | All of the mentioned |
Answer» B. Protected | |
1649. |
Which of these class extend InputStream class? |
A. | ObjectStream |
B. | ObjectInputStream |
C. | ObjectOutput |
D. | ObjectInput |
Answer» C. ObjectOutput | |
1650. |
class A { protected int method1(int a, int b) { return 0; } } Which is valid in a class that extends class A? |
A. | public int method1(int a, int b) {return 0; } |
B. | private int method1(int a, int b) { return 0; } |
C. | public short method1(int a, int b) { return 0; } |
D. | static protected int method1(int a, int b) { return 0; } |
Answer» B. private int method1(int a, int b) { return 0; } | |