Java MCQ Questions and Answers

Java MCQs

 

1. Who is the Developer of Java ?

A) Dennis Ritchie
B) James Gosling
C) Bjarne Stroustrup
D) Charles Babbage

Show Answer
B) James Gosling

 

2. What was Java Name Before ?

A) Java
B) Javax
C) classes and Java
D) Oak

Show Answer
D) Oak

 

3. In which year Java was Developed ?

A) 1991
B) 1972
C) 1979
D) 1995

Show Answer
A) 1991

 

4. What is the extension of Java ?

A) .gt
B) .oak
C) .java
D) .exe

Show Answer
C) .java

 

5. Java was Developed By ?

A) Sun MicroSystems
B) Oracle
C) Microsoft
D) ANSI

Show Answer
A) Sun MicroSystems

 

6. Which of the following are flavours of Java ?

A) J2SE
B) J2EE
C) J2ME
D) All of above

Show Answer
D) All of above

 

7. Whose product is Java right now ?

A) Sun MicroSystems
B) Microsoft
C) ANSI
D) Oracle

Show Answer
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

Show Answer
A) JDK alpha & Beta

 

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

Show Answer
B) javac 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

Show Answer
A) java class_name

 

11. In java, JDK stands for ?

A) java Design Kit
B) java Developer Kit
C) java Development Kit
D) None of these

Show Answer
C) java Development Kit

 

12. In java, JRE stands for ?

A) java Running Environment
B) java Runtime Environment
C) java Runtime Execution
D) None of these

Show Answer
B) java Runtime Environment

 

13. In java, JVM stands for ?

A) java Virtual Machine
B) java Verification Machine
C) java Virtual Moment
D) None of these

Show Answer
A) java Virtual Machine

 

14. Which of the following is Features of Java ?

A) Platform Independent
B) Simple & Secure
C) Dynamic
D) All of above

Show Answer
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

Show Answer
b) java.lang package

 

16. In java, Scanner class is defined in ?

a) java.util package
b) java.lang package
c) java.io package
d) All of above

Show Answer
a) java.util package

 

17. In java, Scanner class is used to take input at ?

a) Compile-time
b) Run-time
c) both a &b
d) none

Show Answer
b) Run-time

 

18. Which Stream is used for input ?

a) System.out
b) System.in
c) Scanner
d) System

Show Answer
b) System.in

 

19. Which Stream is used for output ?

a) System.out
b) System.in
c) Scanner
d) none

Show Answer
a) System.out

 

20. Which Scanner class method is used to read integer value?

a) nextint()
b) next()
c) readInt()
d) nextInteger()

Show Answer
a) nextint()

 

21. Which Scanner class method is used to read String value?

a) nextLine()
b) next()
c) readString()
d) Both a & b

Show Answer
d) Both a & b

 

22. How Many types of Datatype in Java?

a) One
b) Two
c) Three
d) none

Show Answer
b) Two

 

23. How many primitive Datatype in Java?

a) 4
b) 6
c)7
d) 8

Show Answer
d) 8

 

24. What is the size of char Datatype ?

a) 1 Byte
b) 2 Bytes
c) 4 Bytes
d) none

Show Answer
b) 2 Bytes

 

25. What is the Default value of Boolean Datatype?

a) true
b) false
c) true/false
d) none

Show Answer
b) false

 

26. Which of the following is smallest integer Datatype?

a) short
b) int
c) long
d) byte

Show Answer
d) byte

 

27. Which of the following Datatypes comes under floating Datatypes

a) long
b) double
c) float
d) Both b & c

Show Answer
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

Show Answer
c) -128 to 127

 

29. How many loops are their in java?

a) Two
b) Three
c) Four
d) none

Show Answer
c) Four

 

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

Show Answer
b) do while loop

 

31. Do while loop is also known as loop ?

a) entry control
b) exit control
c) both a & b
d) none

Show Answer
b) exit control

 

32. Which of the following loops are Entry controlled loop?

a) while
b) do while
c) for loop
d) Both a & c

Show Answer
d) Both a & c

 

33. What is the purpose for using loop?

a) for repeatation
b) check condition
c) finding errors
d) none

Show Answer
a) for repeatation

 

34. Which loop is best suitable for Arrays in java?

a) for loop
b) for-each loop
c) while loop
d) do while loop

Show Answer
b) for-each loop

 

35. Which of following is not a part of Binary Operator?

a) Assignment operator
b) Arithmetic Operator
c) Relational Operator
d) Logical Operator

Show Answer
a) Assignment operator

 

36. Which of following is not a arithmetic operator?

a) +
b) *
c) %
d) &

Show Answer
d) &

 

37. How many types of Logical operators ?

a) Two
b) Three
c) Four
d) None

Show Answer
b) Three

 

38. Relational operator is Used for?

a) comparision
b) assignment
c) finding errors
d) all of above

Show Answer
a) comparision

 

39. Which of the following is Bitwise AND operator?

a) &&
b) ||
c)!
d) &

Show Answer
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

Show Answer
c) Ternary Operator

 

41. What is the Default value of Static variable?

a) 0
b) 1
c) garbage
d) none

Show Answer
a) 0

 

42. A variable which is Declared inside the method called ?

a) Instance variable
b) Local variable
c) Static variable
d) none

Show Answer
b) Local variable

 

43. Which of these selection statements test only for Equality?

a) if
b) switch
c) if & switch
d) none

Show Answer
b) switch

 

44. If statement execute or skip statement depending on the expression?

a) boolean
b) double
c) integeric
d) none

Show Answer
a) boolean

 

45. What does the expression double n=10/0; return ?

A) 0
B) Infinity
C) Invalid Expression
D) Exception

Show Answer
B) Infinity

 

46. What is the reason of portability & security of Java ?

A) Bytecode
B) Applet
C) Exception Handling
D) Dynamic

Show Answer
A) Bytecode

 

47. Which package contains the System class ?

A) java.util package
B) java.lang package
C) java.awt package
D) java.io package

Show Answer
B) java.lang package

 

48. Java is case sensitive ?

A) true
B) false
C) May be true or false
D) Depends on Compiler

Show Answer
A) true

 

49. Java was publicly released in ?

A) 25-05-1991
B) 28-05-1993
C) 27-05-1995
D) 26-05-1996

Show Answer
C) 27-05-1995

 

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

Show Answer
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

Show Answer
a) 1

 

52. What is the default data type of a decimal value in java ?

A) int
B) long
C) float
D) double

Show Answer
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();

Show Answer
C) 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

Show Answer
b) 10 20 20

 

55. In java, Scanner is pre-defined ?

A) method
B) package
C) variable
D) class

Show Answer
D) class

 

Leave a Comment