Java MCQs
1. Who is the Developer of Java ?
A) Dennis Ritchie
B) James Gosling
C) Bjarne Stroustrup
D) Charles Babbage
2. What was Java Name Before ?
A) Java
B) Javax
C) classes and Java
D) Oak
3. In which year Java was Developed ?
A) 1991
B) 1972
C) 1979
D) 1995
4. What is the extension of Java ?
A) .gt
B) .oak
C) .java
D) .exe
5. Java was Developed By ?
A) Sun MicroSystems
B) Oracle
C) Microsoft
D) ANSI
6. Which of the following are flavours of Java ?
A) J2SE
B) J2EE
C) J2ME
D) All of above
7. Whose product is Java right now ?
A) Sun MicroSystems
B) Microsoft
C) ANSI
D) Oracle
8. What is the first version of Java ?
A) JDK alpha & Beta
B) JDK 1.0
C) JDK 15
D) All of above
9. What is the Compilation Process of Java Program ?
A) java class_name.java
B) javac class_name.java
C) javac class_name
D) class_name.java
10. What is the Execution Process of Java Program?
A) java class_name
B) javac class_name
C) class_name.java
D) class_name java
11. In java, JDK stands for ?
A) java Design Kit
B) java Developer Kit
C) java Development Kit
D) None of these
12. In java, JRE stands for ?
A) java Running Environment
B) java Runtime Environment
C) java Runtime Execution
D) None of these
13. In java, JVM stands for ?
A) java Virtual Machine
B) java Verification Machine
C) java Virtual Moment
D) None of these
14. Which of the following is Features of Java ?
A) Platform Independent
B) Simple & Secure
C) Dynamic
D) All of above
15. In java, System class is defined in ?
a) java.util package
b) java.lang package
c) java.io package
d) none
16. In java, Scanner class is defined in ?
a) java.util package
b) java.lang package
c) java.io package
d) All of above
17. In java, Scanner class is used to take input at ?
a) Compile-time
b) Run-time
c) both a &b
d) none
18. Which Stream is used for input ?
a) System.out
b) System.in
c) Scanner
d) System
19. Which Stream is used for output ?
a) System.out
b) System.in
c) Scanner
d) none
20. Which Scanner class method is used to read integer value?
a) nextint()
b) next()
c) readInt()
d) nextInteger()
21. Which Scanner class method is used to read String value?
a) nextLine()
b) next()
c) readString()
d) Both a & b
22. How Many types of Datatype in Java?
a) One
b) Two
c) Three
d) none
23. How many primitive Datatype in Java?
a) 4
b) 6
c)7
d) 8
24. What is the size of char Datatype ?
a) 1 Byte
b) 2 Bytes
c) 4 Bytes
d) none
25. What is the Default value of Boolean Datatype?
a) true
b) false
c) true/false
d) none
26. Which of the following is smallest integer Datatype?
a) short
b) int
c) long
d) byte
27. Which of the following Datatypes comes under floating Datatypes
a) long
b) double
c) float
d) Both b & c
28. What is the Range of byte DataType is
a) -128 to 128
b) -127 to 128
c) -128 to 127
d) -127 to 127
29. How many loops are their in java?
a) Two
b) Three
c) Four
d) none
30. Which loop always execute atleast once, even condition is false?
a) while loop
b) do while loop
c) for loop
d) for-each loop
31. Do while loop is also known as loop ?
a) entry control
b) exit control
c) both a & b
d) none
32. Which of the following loops are Entry controlled loop?
a) while
b) do while
c) for loop
d) Both a & c
33. What is the purpose for using loop?
a) for repeatation
b) check condition
c) finding errors
d) none
34. Which loop is best suitable for Arrays in java?
a) for loop
b) for-each loop
c) while loop
d) do while loop
35. Which of following is not a part of Binary Operator?
a) Assignment operator
b) Arithmetic Operator
c) Relational Operator
d) Logical Operator
36. Which of following is not a arithmetic operator?
a) +
b) *
c) %
d) &
37. How many types of Logical operators ?
a) Two
b) Three
c) Four
d) None
38. Relational operator is Used for?
a) comparision
b) assignment
c) finding errors
d) all of above
39. Which of the following is Bitwise AND operator?
a) &&
b) ||
c)!
d) &
40. Which operator is used for alternate of if-else statement?
a) Arithmetic Operator
b) Bitwise Operator
c) Ternary Operator
d) Incr/Decr Operator
41. What is the Default value of Static variable?
a) 0
b) 1
c) garbage
d) none
42. A variable which is Declared inside the method called ?
a) Instance variable
b) Local variable
c) Static variable
d) none
43. Which of these selection statements test only for Equality?
a) if
b) switch
c) if & switch
d) none
44. If statement execute or skip statement depending on the expression?
a) boolean
b) double
c) integeric
d) none
45. What does the expression double n=10/0; return ?
A) 0
B) Infinity
C) Invalid Expression
D) Exception
46. What is the reason of portability & security of Java ?
A) Bytecode
B) Applet
C) Exception Handling
D) Dynamic
47. Which package contains the System class ?
A) java.util package
B) java.lang package
C) java.awt package
D) java.io package
48. Java is case sensitive ?
A) true
B) false
C) May be true or false
D) Depends on Compiler
49. Java was publicly released in ?
A) 25-05-1991
B) 28-05-1993
C) 27-05-1995
D) 26-05-1996
50. Which of the following are correct advantage of Java ?
A) Java is Simple
B) Java is Secure
C) Java is Portable
D) All of above
51. What will be the output of Program?
class A
{
public static void main(String] args) {
int n=257;
byte b=(byte)n;
System.out.print(b);
}
}
a) 1
b) -128
c) Error
d) None of above
52. What is the default data type of a decimal value in java ?
A) int
B) long
C) float
D) double
53. Which one is a valid declaration of boolean datatype ?
A) boolean b=0;
B) boolean b=”false’;
C) boolean b=false;
D) boolean b=false();
54. Predict the output of Program?
class A
{ public static void main(String) args) {
int n=10;
System.out.print(n);
if(n==10)
{ ne20;
System.out.print(n);
}
System.out.print(n);
}
a) 10 20 10
b) 10 20 20
c) 10 10 10
d) None of above
55. In java, Scanner is pre-defined ?
A) method
B) package
C) variable
D) class