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.
| 1551. |
Can 8 byte long data type be automatically type cast to 4 byte float data type? |
| A. | True |
| B. | False |
| Answer» B. False | |
| 1552. |
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 | |
| 1553. |
What is the output of this program? class Modulus { public static void main(String args[]) { double a = 25.64; int b = 25; a = a % 10; b = b % 10; System.out.println(a + " " + b); } } |
| A. | 5.640000000000001 5 |
| B. | 5.640000000000001 5.0 |
| C. | 5 5.640000000000001 |
| D. | 5 5 |
| Answer» B. 5.640000000000001 5.0 | |
| 1554. |
What is the output of this program? |
| A. | 1 1 |
| B. | 0 1 |
| C. | 1.5 1 |
| D. | 1.5 1 |
| Answer» D. 1.5 1 | |
| 1555. |
Decrement operator, −−, decreases value of variable by what number? |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| D. | 4 |
| Answer» B. 2 | |
| 1556. |
With x = 0, which of the following are legal lines of Java code for changing the value of x to 1? 1. x++; 2. x = x + 1; 3. x += 1; 4. x =+ 1; |
| A. | 1, 2 & 3 |
| B. | 1 & 4 |
| C. | 1, 2, 3 & 4 |
| D. | 3 & 2 |
| Answer» D. 3 & 2 | |
| 1557. |
Modulus operator, %, can be applied to which of these? |
| A. | Integers |
| B. | Floating – point numbers |
| C. | Both Integers and floating – point numbers. |
| D. | None of the mentioned |
| Answer» D. None of the mentioned | |
| 1558. |
Which of the following can be operands of arithmetic operators? |
| A. | Numeric |
| B. | Boolean |
| C. | Characters |
| D. | Both Numeric & Characters |
| Answer» E. | |
| 1559. |
An array elements are always stored in ________ memory locations? |
| A. | Sequential |
| B. | Random |
| C. | Sequential and Random |
| D. | Binary search |
| Answer» B. Random | |
| 1560. |
Where is array stored in memory? |
| A. | heap space |
| B. | stack space |
| C. | heap space and stack space |
| D. | first generation memory |
| Answer» B. stack space | |
| 1561. |
Can you make an array volatile? |
| A. | True |
| B. | False |
| Answer» B. False | |
| 1562. |
How to copy contents of array? |
| A. | System.arrayCopy() |
| B. | Array.copy() |
| C. | Arrays.copy() |
| D. | Collection.copy() |
| Answer» B. Array.copy() | |
| 1563. |
How to sort an array? |
| A. | Array.sort() |
| B. | Arrays.sort() |
| C. | Collection.sort() |
| D. | System.sort() |
| Answer» C. Collection.sort() | |
| 1564. |
Generics does not work with? |
| A. | SetList |
| B. | Tree |
| C. | Tree |
| D. | Array |
| Answer» E. | |
| 1565. |
What is the output of below snippet? Object[] names = new String[3]; names[0] = new Integer(0); |
| A. | ArrayIndexOutOfBoundsException |
| B. | ArrayStoreException |
| C. | Compilation Error |
| D. | Code runs successfully |
| Answer» C. Compilation Error | |
| 1566. |
What will this code print? int arr[] = new int [5]; System.out.print(arr); |
| A. | 0 |
| B. | value stored in arr[0]. |
| C. | 00000 |
| D. | Garbage value |
| Answer» E. | |
| 1567. |
What is the type of variable ‘b’ and ‘d’ in the below snippet? int a[], b; int []c, d; |
| A. | ‘b’ and ‘d’ are int |
| B. | ‘b’ and ‘d’ are arrays of type int |
| C. | ‘b’ is int variable; ‘d’ is int array |
| D. | ‘d’ is int variable; ‘b’ is int array |
| Answer» D. ‘d’ is int variable; ‘b’ is int array | |
| 1568. |
What is the output of this program? class array_output { public static void main(String args[]) { int array_variable[][] = {{ 1, 2, 3}, { 4 , 5, 6}, { 7, 8, 9}}; int sum = 0; for (int i = 0; i < 3; ++i) for (int j = 0; j < 3 ; ++j) sum = sum + array_variable[i][j]; System.out.print(sum / 5); } } |
| A. | 8 |
| B. | 9 |
| C. | 10 |
| D. | 11 |
| Answer» C. 10 | |
| 1569. |
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] + ""); } } } |
| A. | 1 2 3 4 5 6 7 8 9 10 |
| B. | 0 1 2 3 4 5 6 7 8 9 10 |
| C. | i j k l m n o p q r |
| D. | i i i i i i i i i i |
| Answer» E. | |
| 1570. |
What is the output of this program? class evaluate { public static void main(String args[]) { int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9}; int n = 6; n = arr[arr[n] / 2]; System.out.println(arr[n] / 2); } } |
| A. | 3 |
| B. | 0 |
| C. | 6 |
| D. | 1 |
| Answer» E. | |
| 1571. |
What is the output of this program? class multidimention_array { public static void main(String args[]) { int arr[][] = new int[3][]; arr[0] = new int[1]; arr[1] = new int[2]; arr[2] = new int[3]; int sum = 0; for (int i = 0; i < 3; ++i) for (int j = 0; j < i + 1; ++j) arr[i][j] = j + 1; for (int i = 0; i < 3; ++i) for (int j = 0; j < i + 1; ++j) sum + = arr[i][j]; System.out.print(sum); } } |
| A. | 11 |
| B. | 10 |
| C. | 13 |
| D. | 14 |
| Answer» C. 13 | |
| 1572. |
What is the output of this program? class array_output { public static void main(String args[]) { int array_variable [] = new int[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = i; System.out.print(array_variable[i] + " "); i++; } } } |
| A. | 0 2 4 6 8 |
| B. | 1 3 5 7 9 |
| C. | 0 1 2 3 4 5 6 7 8 9 |
| D. | 1 2 3 4 5 6 7 8 9 10 |
| Answer» B. 1 3 5 7 9 | |
| 1573. |
Which of these is necessary to specify at time of array initialization? |
| A. | Row |
| B. | Column |
| C. | Both Row and Column |
| D. | None of the mentioned |
| Answer» B. Column | |
| 1574. |
Which of these is an incorrect Statement? |
| A. | It is necessary to use new operator to initialize an array. |
| B. | Array can be initialized using comma separated expressions surrounded by curly braces. |
| C. | Array can be initialized when they are declared. |
| D. | None of the mentioned |
| Answer» B. Array can be initialized using comma separated expressions surrounded by curly braces. | |
| 1575. |
What will this code print? int arr[] = new int [5]; System.out.print(arr); |
| A. | 0 |
| B. | value stored in arr[0]. |
| C. | 00000 |
| D. | Class name@ hashcode in hexadecimal form |
| Answer» E. | |
| 1576. |
Which of these is an incorrect array declaration? |
| A. | int arr[] = new int[5] |
| B. | int [] arr = new int[5] |
| C. | int arr[] = new int[5] |
| D. | int arr[] = int [5] new |
| Answer» E. | |
| 1577. |
Which of these operators is used to allocate memory to array variable in Java? |
| A. | malloc |
| B. | alloc |
| C. | new |
| D. | new malloc |
| Answer» D. new malloc | |
| 1578. |
What is the output of this program? class c { public void main( String[] args ) { System.out.println( "Hello" + args[0] ); } } |
| A. | Hello c |
| B. | Hello |
| C. | Hello world |
| D. | Runtime Error |
| Answer» E. | |
| 1579. |
What is the output of this program, if we run as “java main_arguments 1 2 3”? class main_arguments { public static void main(String [] args) { String [][] argument = new String[2][2]; int x; argument[0] = args; x = argument[0].length; for (int y = 0; y < x; y++) System.out.print(" " + argument[0][y]); } } |
| A. | 1 1 |
| B. | 1 0 |
| C. | 1 0 3 |
| D. | 1 2 3 |
| Answer» E. | |
| 1580. |
What is the output of this program? class A { final public int calculate(int a, int b) { return 1; } } class B extends A { public int calculate(int a, int b) { return 2; } } public class output { public static void main(String args[]) { B object = new B(); System.out.print("b is " + b.calculate(0, 1)); } } |
| A. | b is : 2 |
| B. | b is : 1 |
| C. | Compilation Error. |
| D. | An exception is thrown at runtime. |
| Answer» D. An exception is thrown at runtime. | |
| 1581. |
What is the output of this program? class conversion { public static void main(String args[]) { double a = 295.04; int b = 300; byte c = (byte) a; byte d = (byte) b; System.out.println(c + " " + d); } } |
| A. | 38 43 |
| B. | 39 44 |
| C. | 295 300 |
| D. | 295.04 300 |
| Answer» C. 295 300 | |
| 1582. |
What is the output of this program? class char_increment { public static void main(String args[]) { char c1 = 'D'; char c2 = 84; c2++; c1++; System.out.println(c1 + " " + c2); } } |
| A. | E U |
| B. | U E |
| C. | V E |
| D. | U F |
| Answer» B. U E | |
| 1583. |
What is Truncation is Java? |
| A. | Floating-point value assigned to an integer type |
| B. | Integer value assigned to floating type |
| C. | Floating-point value assigned to an Floating type |
| D. | Integer value assigned to floating type |
| Answer» B. Integer value assigned to floating type | |
| 1584. |
If an expression contains double, int, float, long, then whole expression will promoted into which of these data types? |
| A. | long |
| B. | INT |
| C. | double |
| D. | float |
| Answer» D. float | |
| 1585. |
What is the error in this code? byte b = 50; b = b * 50; |
| A. | b can not contain value 100, limited by its range. |
| B. | * operator has converted b * 50 into int, which can not be converted to byte without casting. |
| C. | b can not contain value 50. |
| D. | No error in this code |
| Answer» C. b can not contain value 50. | |
| 1586. |
What is the prototype of the default constructor of this class? public class prototype { } |
| A. | prototype( ) |
| B. | prototype(void) |
| C. | public prototype(void) |
| D. | public prototype( ) |
| Answer» E. | |
| 1587. |
Which of these is necessary condition for automatic type conversion in Java? |
| A. | The destination type is smaller than source type |
| B. | The destination type is larger than source type |
| C. | The destination type can be larger or smaller than source type |
| D. | None of the mentioned |
| Answer» C. The destination type can be larger or smaller than source type | |
| 1588. |
What is the output of this program? class dynamic_initialization { public static void main(String args[]) { double a, b; a = 3.0; b = 4.0; double c = Math.sqrt(a * a + b * b); System.out.println(c); } } |
| A. | 5.0 |
| B. | 25.0 |
| C. | 7.0 |
| D. | Compilation Error |
| Answer» B. 25.0 | |
| 1589. |
Which of these is incorrect string literal? |
| A. | “Hello World” |
| B. | “HelloWorld” |
| C. | “”Hello World”” |
| D. | “Hello world” |
| Answer» E. | |
| 1590. |
What is the output of this program? class variable_scope { public static void main(String args[]) { int x; x = 5; { int y = 6; System.out.print(x + " " + y); } System.out.println(x + " " + y); } } |
| A. | 5 6 5 6 |
| B. | 5 6 5 |
| C. | Runtime error |
| D. | Compilation error |
| Answer» E. | |
| 1591. |
What is the output of this program? class array_output { public static void main(String args[]) { int array_variable [] = new int[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = i/2; array_variable[i]++; System.out.print(array_variable[i] + " "); i++; } } } |
| A. | 0 2 4 6 8 |
| B. | 1 2 3 4 5 |
| C. | 0 1 2 3 4 5 6 7 8 9 |
| D. | 1 2 3 4 5 6 7 8 9 10 |
| Answer» C. 0 1 2 3 4 5 6 7 8 9 | |
| 1592. |
What is the output of this program? class evaluate { public static void main(String args[]) { int a[] = {1,2,3,4,5}; int d[] = a; int sum = 0; for (int j = 0; j < 3; ++j) sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]); System.out.println(sum); } } |
| A. | 38 |
| B. | 39 |
| C. | 40 |
| D. | 41 |
| Answer» D. 41 | |
| 1593. |
Which of these can not be used for a variable name in Java? |
| A. | identifier |
| B. | keyword |
| C. | identifier & keyword |
| D. | none of the mentioned |
| Answer» C. identifier & keyword | |
| 1594. |
Literal can be of which of these data types? |
| A. | integer |
| B. | float |
| C. | boolean |
| D. | all of the mentioned |
| Answer» E. | |
| 1595. |
Literals in java must be appended by which of these? |
| A. | L |
| B. | I |
| C. | D |
| D. | L AND I |
| Answer» E. | |
| 1596. |
Which of these can be returned by the operator & ? |
| A. | Integer |
| B. | Boolean |
| C. | Character |
| D. | Integer or Boolean |
| Answer» E. | |
| 1597. |
Which of these is long data type literal? |
| A. | 0x99fffL |
| B. | ABCDEFG |
| C. | 0x99fffa |
| D. | 99671246 |
| Answer» B. ABCDEFG | |
| 1598. |
How to get UTC time? |
| A. | Time.getUTC(); |
| B. | Date.getUTC(); |
| C. | Instant.now(); |
| D. | TimeZone.getUTC(); |
| Answer» D. TimeZone.getUTC(); | |
| 1599. |
What does LocalTime represent? |
| A. | long diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis(); |
| B. | long diffInMilli = java.time.difference(dateTime1, dateTime2).toMillis(); |
| C. | Date diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis(); |
| D. | Time diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis(); |
| Answer» B. long diffInMilli = java.time.difference(dateTime1, dateTime2).toMillis(); | |
| 1600. |
How is Date stored in database? |
| A. | java.sql.Date |
| B. | java.util.Date |
| C. | Java.sql.DateTime |
| D. | java.util.DateTime |
| Answer» B. java.util.Date | |