☑ MCQ PRACTICE

Object Oriented Programming through Java Unit 1

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

📚 Object Oriented Programming through Java
📖 Unit 1
🎯 MCQs

Object Oriented Programming through Java - Unit-1

1
Which provides runtime environment for java byte code to be executed?
AJDK
BJVM
CJRE
DJAVAC
Correct Answer JVM
2
Which variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed?
ALocal variables
BInstance variables
CClass Variables
DStatic variables
Correct Answer Instance variables
3
Choose a Single Line Comment in Java Language below?
A//Some comments
BSome comments//
C/*Some comments*/
D*/Some comments/*
Correct Answer //Some comments
4
A valid identifier in Java language may contain which characters?
A0-9
BA-Z, a-z
C$, _ (Underscore)
DAll the above
Correct Answer All the above
5
In Java, Multi-line comments are represented by _____________
A//
B/* */
C/# #/
D*/ */
Correct Answer /* */
6
The Primitive data types in java are ____________________
APre-defined data types
BUser-defined data types
CBoth
DNone of the above
Correct Answer Pre-defined data types
7
Which of the following expression is an invalid?
Aint Abc = 12;
BString full_name = "yourname";
Cfloat 4d = 12.3f;
Ddouble d$ = 1234.456d;
Correct Answer float 4d = 12.3f;
8
In java, The instance variable is declared ____________________.
Ainside the method
Binside class but outside the method
Cinside class but outside the method and it is static
Doutside the class
Correct Answer inside class but outside the method
9
A data type is converted into another data type by the programmer is known as ____________?
AType Conversion
BImplicit conversion
CType Casting
DNone of the above
Correct Answer Type Casting
10
Which one is true about a constructor?
AA constructor must have the same name as the class it is declared within.
BA constructor is used to Initialize the objects.
CA constructor may be declared private
DAll of the above
Correct Answer All of the above
11
What are the keywords used to implement a SWITCH case in Java language?
Aswitch, case
Bdefault
Cbreak
DAll
Correct Answer All
12
Which of the following statement is invalid?
Abreak - immediately jumps to end of the loop
Bcontinue - immediately jumps to next interation
Cwhile loop - if the number of iterations are not fixed
Dfor loop - if the number of iterations are not fixed
Correct Answer for loop - if the number of iterations are not fixed
13
Which of the following array declaration is invalid?
ADatatype array_name[] = new DataType[size];
BDatatype[] array_name = new DataType[size];
CDatatype array_name[] = {val1,val2,val3,......valn};
DDatatype array_name[] = new DataType[];
Correct Answer Datatype array_name[] = new DataType[];
14
Do you want to access the data members of a class, you have to create ___________?
Aan object
Ba variable
Ca method
Dan array
Correct Answer an object
15
In java, the String class comes under ___________ package?
Ajava.io
Bjava.lang
Cjava.util
Djava.String
Correct Answer java.lang
16
In java, the System class comes under ___________ package?
Ajava.io
Bjava.lang
Cjava.util
Djava.String
Correct Answer java.lang
17
In java, the Scanner class comes under ___________ package?
Ajava.io
Bjava.lang
Cjava.util
Djava.String
Correct Answer java.util
18
In java, the Console class comes under ___________ package?
Ajava.io
Bjava.lang
Cjava.util
Djava.String
Correct Answer java.io
19
Which of these is an incorrect Statement?
AIt is necessary to use new operator to initialize an array
BArray can be initialized using comma separated expressions surrounded by curly braces
CArray can be initialized when they are declared
DNone of the mentioned
Correct Answer None of the mentioned
20
In a .java file, how many numbers of public types namely class, interface or abstract can be managed?
A1
B2
C3
DAny number
Correct Answer 1
21
Java method overloading implements the OOPS concept ___.
AInheritance
BPolymorphism
CEncapsulation
DNone
Correct Answer Polymorphism

Fill in the Blanks

22 To successfully overload a method in Java, the argument-list or parameter-list must be ___. (Same/Different)
Correct Answer Different
23 A local variable declared inside a method can not be used in expressions without initializing it first. (TRUE / FALSE).
Correct Answer TRUE
24 In Java, an array can be declared without initialization without mentioning the size. (True / False)
Correct Answer A
25 State TRUE or FALSE. An ELSE or ELSE-IF statement in Java can not exist alone without IF statement. (FALSE / TRUE).
Correct Answer TRUE
← Back to All MCQs