

MCQOPTIONS
Saved Bookmarks
This section includes 155 Mcqs, each offering curated multiple-choice questions to sharpen your Java Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
Which three piece of codes are equivalent to line 3? |
A. | 1, 2 and 3 |
B. | 2, 3 and 4 |
C. | 3, 4 and 5 |
D. | 4, 5 and 6 |
Answer» B. 2, 3 and 4 | |
2. |
What will be the output of the program? |
A. | args[2] = 2 |
B. | args[2] = 3 |
C. | args[2] = null |
D. | An exception is thrown at runtime. |
Answer» E. | |
3. |
What will be the output of the program? public class CommandArgsThree { public static void main(String [] args) { String [][] argCopy = new String[2][2]; int x; argCopy[0] = args; x = argCopy[0].length; for (int y = 0; y < x; y++) { System.out.print(" " + argCopy[0][y]); } } } and the command-line invocation is> java CommandArgsThree 1 2 3 |
A. | 0 0 |
B. | 1 2 |
C. | 0 0 0 |
D. | 1 2 3 |
Answer» E. | |
4. |
public class F0091 { public void main( String[] args ) { System.out.println( "Hello" + args[0] ); } } What will be the output of the program, if this code is executed with the command line:> java F0091 world |
A. | Hello |
B. | Hello Foo91 |
C. | Hello world |
D. | The code does not run. |
Answer» E. | |
5. |
What will be the output of the program? public class CommandArgs { public static void main(String [] args) { String s1 = args[1]; String s2 = args[2]; String s3 = args[3]; String s4 = args[4]; System.out.print(" args[2] = " + s2); } } and the command-line invocation is > java CommandArgs 1 2 3 4 |
A. | args[2] = 2 |
B. | args[2] = 3 |
C. | args[2] = null |
D. | An exception is thrown at runtime. |
Answer» E. | |
6. |
What will be the output of the program? public class CommandArgsTwo { public static void main(String [] argh) { int x; x = argh.length; for (int y = 1; y <= x; y++) { System.out.print(" " + argh[y]); } } } and the command-line invocation is > java CommandArgsTwo 1 2 3 |
A. | 0 1 2 |
B. | 1 2 3 |
C. | 0 0 0 |
D. | An exception is thrown at runtime |
Answer» E. | |
7. |
What will be the output of the program? public class X { public static void main(String [] args) { String names [] = new String[5]; for (int x=0; x < args.length; x++) names[x] = args[x]; System.out.println(names[2]); } } and the command line invocation is> java X a b |
A. | names |
B. | |
C. | Compilation fails |
D. | An exception is thrown at runtime |
Answer» C. Compilation fails | |
8. |
Java SE 15 version released on? |
A. | March 19, 2019 |
B. | March 17, 2020 |
C. | September 17, 2019 |
D. | September 15, 2020 |
Answer» E. | |
9. |
Java Source Code is compiled into ______________. |
A. | .Obj |
B. | Source Code |
C. | Bytecode |
D. | .Exe |
Answer» D. .Exe | |
10. |
Which three are valid declarations of a char?1. char c1 = 064770;2. char c2 = 'face';3. char c3 = 0xbeef;4. char c4 = \u0022;5. char c5 = '\iface';6. char c6 = '\uface'; |
A. | 1, 2, 4 |
B. | 1, 3, 6 |
C. | 3, 5 |
D. | 5 only |
Answer» C. 3, 5 | |
11. |
Sun Microsystems released the first public implementation as Java 1.0 in? |
A. | 1994 |
B. | 1995 |
C. | 1996 |
D. | 1997 |
Answer» D. 1997 | |
12. |
Enums were introduced in? |
A. | Java 4.0 |
B. | Java 8.0 |
C. | Java 5.0 |
D. | Java 6.0 |
Answer» D. Java 6.0 | |
13. |
In which year, Sun Microsystems released much of its Java virtual machine? |
A. | 2005 |
B. | 2006 |
C. | 2007 |
D. | 2008 |
Answer» C. 2007 | |
14. |
After first public release java was targeted at ______________________. |
A. | Internet development |
B. | Search Engine Development |
C. | Desktop Development |
D. | Operating System Development |
Answer» B. Search Engine Development | |
15. |
Basic aim of java was to solve the problem of connecting many household machines together. The was achieved using |
A. | Java data kit |
B. | Java defination kit |
C. | Java design kit |
D. | Java development kit |
Answer» E. | |
16. |
HTML based Java Documentary help can be accessed using ______________. |
A. | javahelp |
B. | javamanual |
C. | javadoc |
D. | None of these |
Answer» D. None of these | |
17. |
First public implementation of java was _____________ |
A. | Java 1.2 |
B. | Java 1.0 |
C. | Java 1.1 |
D. | Java Premium 1.0 |
Answer» C. Java 1.1 | |
18. |
Which of the following is used to interpret and execute Java Applet Classes hosted by HTML. |
A. | appletviewer |
B. | appletwatcher |
C. | appletshow |
D. | appletscreen |
Answer» B. appletwatcher | |
19. |
Which of the following personality is called as father of Java Programming language |
A. | James Gosling |
B. | Larry Page |
C. | Bjarne Stroustrup |
D. | None of these |
Answer» B. Larry Page | |
20. |
Why OAK was renamed to Java ? |
A. | because the language was unsuccessful , so they created another version and changed its name to java. |
B. | because the name was not relevant to the language they created |
C. | because there was another language called Oak |
D. | None of these |
Answer» D. None of these | |
21. |
What will be the output of the program?Note: The command line invocation is> java X a b |
A. | names |
B. | |
C. | Compilation fails |
D. | An exception is thrown at runtime |
Answer» C. Compilation fails | |
22. |
Which kind of language java is ? |
A. | Object Oriented |
B. | Procedural |
C. | Event Driven |
D. | None of these |
Answer» B. Procedural | |
23. |
Java was publicly released in _______________ . |
A. | 25-05-1995 |
B. | 27-05-1995 |
C. | 29-05-1995 |
D. | 28-05-1995 |
Answer» C. 29-05-1995 | |
24. |
Java was designed by _________________. |
A. | Microsoft |
B. | Mozilla Corporation |
C. | Sun Microsystems |
D. | Amazon Inc. |
Answer» D. Amazon Inc. | |
25. |
Earlier name of Java Programming language was |
A. | Eclipse |
B. | OAK |
C. | Netbean |
D. | D |
Answer» C. Netbean | |
26. |
Java is a ________ programming language. |
A. | high-level |
B. | Middle-level |
C. | Low-level |
D. | None of the above |
Answer» B. Middle-level | |
27. |
Which of the following is/are correct advantage of java? |
A. | Java is Simple |
B. | Java is Secure |
C. | Java is Portable |
D. | All of the above |
Answer» E. | |
28. |
In the beginning, Java was created in order to |
A. | Perform Operations on the Internet |
B. | Connect many household machines |
C. | Create Strong Programming alternative to C++ |
D. | ALL of the above |
Answer» C. Create Strong Programming alternative to C++ | |
29. |
All Java components require names. Names used for classes, variables, and methods are called? |
A. | Variables |
B. | identifiers |
C. | Access Modifiers |
D. | Java Modifiers |
Answer» C. Access Modifiers | |
30. |
Default, public , protected, private are? |
A. | Access Modifier |
B. | Non-access Modifiers |
C. | both a and b |
D. | It's variable |
Answer» B. Non-access Modifiers | |
31. |
jar stands for _____________. |
A. | Java Application Runner |
B. | Java Archive |
C. | Java Archive Runner |
D. | None of these |
Answer» C. Java Archive Runner | |
32. |
How to compile java code in command prompt? |
A. | javac filename.java |
B. | java filename.java |
C. | javac filename |
D. | java filename |
Answer» B. java filename.java | |
33. |
Java is case sensitive? |
A. | True |
B. | False |
C. | Depends On Complier |
D. | May be true or false |
Answer» B. False | |
34. |
How to run java program in command prompt? |
A. | javac filename.java |
B. | java filename.java |
C. | javac filename |
D. | java filename |
Answer» E. | |
35. |
What is true in Java? |
A. | For all class names the first letter should be in Upper Case. |
B. | All method names should start with a Lower Case letter. |
C. | Name of the program file should exactly match the class name. |
D. | All of the above |
Answer» E. | |
36. |
Which of the following is not a keyword in Java? |
A. | assert |
B. | boolean |
C. | abstract |
D. | finalize |
Answer» E. | |
37. |
Which of the following is not a keyword in Java? |
A. | transient |
B. | instanceof |
C. | emun |
D. | strictfp |
Answer» D. strictfp | |
38. |
Single line comment starts with _________ in Java. |
A. | /** |
B. | // |
C. | /* |
D. | None of these |
Answer» D. None of these | |
39. |
What is JRE? |
A. | JRE is a java based GUI application. |
B. | JRE is an implementation of the Java Virtual Machine which executes Java programs. |
C. | JRE is an application development framework. |
D. | None of the above |
Answer» C. JRE is an application development framework. | |
40. |
What will be the output of the program?Note: The command-line invocation is> java CommandArgsTwo 1 2 3 |
A. | 0 1 2 |
B. | 1 2 3 |
C. | 0 0 0 |
D. | An exception is thrown at runtime |
Answer» E. | |
41. |
What will be the output of the program, if this code is executed with the command line:> java F0091 world |
A. | Hello |
B. | Hello Foo91 |
C. | Hello world |
D. | The code does not run. |
Answer» E. | |
42. |
What will be the output of the prograNote: The command-line invocation is > java CommandArgs 1 2 3 4 |
A. | args[2] = 2 |
B. | args[2] = 3 |
C. | args[2] = null |
D. | An exception is thrown at runtime. |
Answer» E. | |
43. |
What will be the output of the program?Note: The command-line invocation is> java CommandArgsThree 1 2 3 |
A. | 0 0 |
B. | 1 2 |
C. | 0 0 0 |
D. | 1 2 3 |
Answer» E. | |
44. |
Which three piece of codes are equivalent to line 3?1. final int k = 4;2. public int k = 4;3. static int k = 4;4. abstract int k = 4;5. volatile int k = 4;6. protected int k = 4; |
A. | 1, 2 and 3 |
B. | 2, 3 and 4 |
C. | 3, 4 and 5 |
D. | 4, 5 and 6 |
Answer» B. 2, 3 and 4 | |
45. |
Which three are legal array declarations?1. int [] myScores [];2. char [] myChars;3. int [6] myScores;4. Dog myDogs [];5. Dog myDogs [7]; |
A. | 1, 2, 4 |
B. | 2, 4, 5 |
C. | 2, 3, 4 |
D. | All are correct. |
Answer» B. 2, 4, 5 | |
46. |
Which three are valid declarations of a float?1. float f1 = -343;2. float f2 = 3.14;3. float f3 = 0x12345;4. float f4 = 42e7;5. float f5 = 2001.0D;6. float f6 = 2.81F; |
A. | 1, 2, 4 |
B. | 2, 3, 5 |
C. | 1, 3, 6 |
D. | 2, 4, 6 |
Answer» D. 2, 4, 6 | |
47. |
Which four options describe the correct default values for array elements of the types indicated?1. int -> 02. String -> "null"3. Dog -> null4. char -> '\u0000'5. float -> 0.0f6. boolean -> true |
A. | 1, 2, 3, 4 |
B. | 1, 3, 4, 5 |
C. | 2, 4, 5, 6 |
D. | 3, 4, 5, 6 |
Answer» C. 2, 4, 5, 6 | |
48. |
Which of the following are legal lines of Java code?int w = (int)888.8;byte x = (byte)100L;long y = (byte)100;byte z = (byte)100L; |
A. | 1 and 2 |
B. | 2 and 3 |
C. | 3 and 4 |
D. | All statements are correct. |
Answer» E. | |
49. |
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 | |
50. |
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. | |
D. | all of the mentioned |
Answer» E. | |