90
76.7k

610+ Java Programming Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Bachelor of Computer Applications (BCA) , Bachelor of Science in Computer Science (BSc CS) , Master of Computer Applications (MCA) , Programming Languages .

1.

Who is considered as the creator of JAVA ?

A. Dennis Richie
B. Ken Thompson
C. James Gosling
D. Bjarne Stroupstrup
Answer» C. James Gosling
2.

Which of the following statements about the Java language is true?

A. Java supports only Procedural Oriented Programming approach
B. Both Procedural and Object Oriented Programming are supported in Java
C. Java supports only Object Oriented Programming approach
D. None of the Above
Answer» B. Both Procedural and Object Oriented Programming are supported in Java
3.

JRE stands for

A. Java Realtime Environment
B. Java Rapid Enterprise
C. Java Runtime Environment
D. None of the above
Answer» C. Java Runtime Environment
4.

Java source files are compiled and converted to

A. Object code
B. machine code
C. Bytecode
D. executable file
Answer» C. Bytecode
5.

JVM is ___________for bytecode.

A. a compiler
B. an interpreter
C. assembler
D. none of the above
Answer» B. an interpreter
6.

What is the size of int data type in java?

A. 1 bytes
B. 2 bytes
C. 4 bytes
D. 8 bytes
Answer» C. 4 bytes
7.

Which is a valid float literal?

A. 1.23
B. 2
C. 1.23d
D. 1.23f
Answer» D. 1.23f
8.

What is the numerical range of a char in Java?

A. -128 to 127
B. 0 to 256
C. 0 to 32767
D. 0 to 65535
Answer» D. 0 to 65535
9.

Which of these coding types is used for data type char in Java?

A. ASCII
B. ISO-LATIN-1
C. UNICODE
D. None of the mentioned
Answer» C. UNICODE
10.

Which of these values can a boolean variable contain?

A. True & False
B. 0 & 1
C. Any integer value.
D. Both a & b
Answer» A. True & False
11.

Which one of the following is a valid identifier in java?

A. x1
B. 1x
C. $x
D. x 1
Answer» A. x1
12.

Which operator is used to implement unsigned right shift of an integer?

A. <<
B. >>
C. <<<
D. >>>
Answer» D. >>>
13.

Which one of the following is a jump statement in java?

A. goto
B. jump
C. break
D. if
Answer» C. break
14.

Which of these operators is used to allocate memory to array variable in Java?

A. malloc
B. alloc
C. new
D. new malloc
Answer» C. new
15.

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

A. do-while
B. while
C. for
D. None of the mentioned
Answer» A. do-while
16.

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» B. The destination type is larger than source type.
17.

What is the error in this code? byte b = 50; b = b * 50;

A. b can not store the result 2500, 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» B. * operator has converted b * 50 into int, which can not be converted to byte without casting.
18.

Which of these is an incorrect array declaration?

A. int arr[] = new int[5];
B. int [] arr = new int[5];
C. int arr[]; arr = new int[5];
D. int arr[] = int [5] new
Answer» D. int arr[] = int [5] new
19.

Which of these selection statements test only for equality?

A. if
B. switch
C. Both a & b
D. None of the mentioned
Answer» B. switch
20.

Which of these are selection statements in Java?

A. if
B. for
C. continue
D. all of these
Answer» A. if
21.

Which of these jump statements can skip processing remainder of code in its body for a particular iteration?

A. break
B. return
C. exit
D. continue
Answer» D. continue
22.

What is the value of the expression 2 & 3 ?

A. 2
B. 3
C. 6
D. 5
Answer» A. 2
23.

What is the value of the expression 8 << 2 ?

A. 2
B. 32
C. 1 6
D. 5
Answer» B. 32
24.

The keyword used to create a constant variable

A. const
B. static
C. final
D. none of these
Answer» C. final
25.

What is stored in the object obj in following lines of code? box obj;

A. Memory address of allocated memory of object.
B. NULL
C. Any arbitrary pointer
D. Garbage
Answer» B. NULL
26.

Which of the following is a valid declaration of an object of class Box?

A. Box obj = new Box();
B. Box obj = new Box;
C. obj = new Box();
D. new Box obj;
Answer» A. Box obj = new Box();
27.

Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class.

A. static
B. final
C. abstract
D. public
Answer» A. static
28.

Variables declared with in a class are called

A. Identifier
B. local variable
C. instance variable
D. global variable
Answer» C. instance variable
29.

Variables declared within a method or block are called

A. Static variable
B. local variable
C. instance variable
D. global variable
Answer» B. local variable
30.

Defining methods with same name and different no. of parameters are called

A. Method overriding
B. method overloading
C. Dynamic method dispatch
D. none of the above
Answer» B. method overloading
31.

_________ is used to initialize objects.

A. Methods
B. arguments
C. constructors
D. new keyword
Answer» C. constructors
32.

What is the return type of Constructors?

A. int
B. float
C. void
D. None of the mentioned
Answer» D. None of the mentioned
33.

Which of the following is a method having same name as that of its class?

A. finalize
B. delete
C. class
D. constructor
Answer» D. constructor
34.

Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?

A. delete
B. free
C. new
D. None of the mentione
Answer» D. None of the mentione
35.

Which of these access specifiers must be used for main() method?

A. private
B. public
C. protected
D. None of the mentioned
Answer» B. public
36.

Which of these is used to access member of class before object of that class is created?

A. public
B. private
C. static
D. protected
Answer» C. static
37.

The keyword used to create an object

A. class
B. this
C. new
D. malloc
Answer» C. new
38.

The keyword used to refer the current object

A. class
B. this
C. new
D. malloc
Answer» B. this
39.

The method which is automatically invoked during garbage collection.

A. destructor
B. terminate()
C. finalize()
D. destroy()
Answer» C. finalize()
40.

Which class cannot have a subclass in java

A. abstract class
B. parent class
C. final class
D. None of above
Answer» C. final class
41.

Which is the keyword used to inherit a class to another?

A. Inherits
B. extends
C. implements
D. import
Answer» B. extends
42.

The use of final keyword with method definition

A. Supports method overriding
B. implements dynamic method dispatch
C. Prevents method overriding
D. none of these
Answer» C. Prevents method overriding
43.

Identify the type of inheritance when two or more subclasses inherit the properties of a super class.

A. Multiple inheritance
B. Single inheritance
C. Multilevel inheritance
D. Hierarchical inheritance
Answer» D. Hierarchical inheritance
44.

The keyword used inside a class to refer to its immediate super class is

A. super
B. parent
C. base
D. none of these
Answer» A. super
45.

Which of the following is true in the case of abstract class

A. Abstract constructors cannot be created.
B. Abstract classes can not be inherited.
C. An abstract class contains only abstract methods.
D. All of the above.
Answer» A. Abstract constructors cannot be created.
46.

Which of these keywords are used to define an abstract class?

A. abst
B. abstract
C. Abstract
D. abstract class
Answer» B. abstract
47.

If a class inheriting an abstract class does not define all of its function then it will be known as?

A. abstract
B. A simple class
C. Static class
D. None of the mentioned
Answer» A. abstract
48.

Which of these is not a correct statement?

A. Every class containing abstract method must be declared abstract.
B. Abstract class defines only the structure of the class not its implementation.
C. Abstract class can be initiated by new operator.
D. Abstract class can be inherited.
Answer» C. Abstract class can be initiated by new operator.
49.

Which method defined in Integer class can be used to convert a whole number in string type to primitive int type.

A. valueOf()
B. intValue()
C. parseInt()
D. getInteger()
Answer» C. parseInt()
50.

The method sqrt() is defined in the class

A. System
B. Root
C. Math
D. Arithmetic
Answer» C. Math

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.