SlideShare a Scribd company logo
MCQs BANK
Page: 1
Object Oriented
Programming
Topic: Basic OOP concepts
Instructions:
This MCQs Bank contains question
and solution on adjacent(even-odd)
pages. First try to solve the MCQ by
yourself, then look for the solution.
Best viewed in “single page view”
in PDF viewer.
MCQs BANK No.: 2
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 1
When you program for the Java
platform, you write source code in
_________ files. Fill in the blank.
a) .class
b) .cpp
c) .java
d) .html
Page: 2
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 1 (Solution)
Ans: c) .java
Explanation:
When you program for the Java
platform, you write source code in
.java files and then compile them.
Page: 3
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 2
The java compiler checks your java
code against the language's syntax
rules, then writes out bytecodes in
________ files. Fill in the blank.
a) .class
b) .java
c) .exe
d) .obj
Page: 4
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 2 (Solution)
Ans: a) .class
Explanation: The compiler checks
your code against the language's
syntax rules, then writes out
bytecodes in .class files.
Page: 5
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 3
Which of the following files the
JVM(Java virtual machine) reads
and interprets?
a) .class
b) .java
c) .exe
d) .obj
Page: 6
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 3 (Solution)
Ans: a) .class
Explanation:
At run time, the JVM reads and
interprets .class files and executes
the program's instructions on the
native hardware platform for which
the JVM was written.
Page: 7
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 4
Identify the correct match
combination.
a) 1-x, 2-w, 3-z, 4-y
b) 1-w, 2-x, 3-z, 4-y
c) 1-x, 2-w, 3-y, 4-z
d) 1-y, 2-w, 3-z, 4-x
Page: 8
1) JVM w) Implicit memory
management
2) Garbage
collection
x) Bytecode
3) Objects y) Pool of memory
4) Heap z) Instance variables
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 4 (Solution)
Ans: a) 1-x, 2-w, 3-z, 4-y
Explanation: At run time, the JVM reads
and interprets Bytecode ( in .class files) and
executes the program's instructions on the
native hardware platform for which the JVM
was written.
When your Java application creates an object
instance at run time, the JVM automatically
allocates memory space for that object from
the heap, which is a pool of memory set
aside for your program to use. The Java
garbage collector runs in the background,
keeping track of which objects the application
no longer needs and reclaiming memory from
them. This approach to memory handling is
called implicit memory management because
it doesn't require you to write any memory-
handling code. Data field members of an
object is called instance variables.
Page: 9
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 5
Which of the following process is
used by objects for communication
and coordination.
a) method calling
b) shared memory
c) stack
d) interpreter
Page: 10
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 5 (Solution)
Ans: a) method calling
Explanation: Objects talk to other
objects by sending messages
(method calls in the Java language).
Page: 11
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 6
____________ access means the
object's attributes are accessible
only within the object itself. Fill in
the blank.
a) private
b) public
c) protected
d) default
Page: 12
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 6 (Solution)
Ans: a) private
Explanation:
On the Java platform, you can use
access specifiers to vary the
nature of object relationships from
public to private.
Public access is wide open,
whereas private access means the
object's attributes are accessible
only within the object itself.
Page: 13
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 7
OOP introduces the concept of
inheritance, where a subclass can
"copy" the attributes and behavior of
the super class. If some of those
attributes or behaviors need to
changed in subclass, then you need
to __________ them. Fill in the
blank.
a) overload
b) override
c) delete
d) integrate
Page: 14
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 7 (Solution)
Ans: b) override
Explanation:
Overriding is a feature that allows a
subclass or child class to provide a
specific implementation of a method
that is already provided by one of its
super-classes or parent classes.
You only change what you need to
change in order to create
specialized objects.
Page: 15
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 8
Which of the following is a
fundamental feature of object-
oriented programming language?
a) automatic garbage collection
b) creating objects and manipulating
objects
c) platform independence
d) all of the above
Page: 16
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 8 (Solution)
Ans: b) creating objects and
manipulating objects
Explanation:
Object-oriented programming is
centered on creating objects,
manipulating objects, and making
objects work together.
This allows you to create modular
programs and reusable code. It is the
fundamental feature of Object-oriented
programming languages.
Automatic garbage collection and
platform independence are features
specific to java(not present in all OOP
language, such as C++).
Page: 17
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 9
Which of the following gives
platform independence to java
programs?
a) Bytecode
b) JVM
c) Both (a) and (b)
d) None of these
Page: 18
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 9 (Solution)
Ans: c) Both (a) and (b)
Explanation: JVM is needed in
order to run Java programs. The
programs are compiled into Java
Virtual Machine code called
bytecode.
The bytecode is machine
independent and is able to run on
any machine that has a Java Virtual
Machine. With Java, the program
need only be compiled once, and the
bytecode generated by the Java
compiler can run on any platform.
Page: 19
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 10
______________ is the capability for
a program to perform several tasks
simultaneously within a program. Fill
in the blank.
a) Polymorphism
b) Multithreading
c) Exception Handling
d) Platform Independence
Page: 20
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 10 (Solution)
Ans: b) Multithreading
Explanation:
Multithreading is the capability for a
program to perform several tasks
simultaneously within a program. In
Java, multithreaded programming
has been smoothly integrated into it,
while in other languages, operating
system-specific procedures have to
be called in order to enable
multithreading. Multithreading is a
necessity in visual and network -
programming.
Page: 21
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 11
Consider the following 2
statements(S1 and S2).
(S1) byte data type is a 8-bit signed
two's complement integer.
(S2) Default value is 0.
Which of the following is correct.
a) S1 is TRUE and S2 is FALSE
b) S1 is FALSE and S2 is TRUE
c) Both S1 and S2 are TRUE
d) Both S1 and S2 are FALSE
Page: 22
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 11 (Solution)
Ans: c) Both S1 and S2 are TRUE
Explanation:
byte data type is a 8-bit signed two's
complement integer.
Minimum value is -128 (-2^7)
Maximum value is 127
(inclusive)(2^7 -1)
Default value is 0
Page: 23
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 12
byte data type in java is used to
save space in large arrays, mainly
in place of integers, since a byte is
______ times smaller than an int.
Fill in the blank.
a) two
b) three
c) four
d) eight
Page: 24
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 12 (Solution)
Ans: c) four
Explanation:
Byte data type is used to save space
in large arrays, mainly in place of
integers, since a byte is four times
smaller than an int.
Int data type is a 32-bit signed two's
complement integer in java.
Page: 25
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 13
Consider the following 2
statements(S1 and S2).
(S1) short data type is a 16-bit
signed two's complement integer.
(S2) Default value is 1.
Which of the following is correct.
a) S1 is TRUE and S2 is FALSE
b) S1 is FALSE and S2 is TRUE
c) Both S1 and S2 are TRUE
d) Both S1 and S2 are FALSE
Page: 26
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 13 (Solution)
Ans: a) S1 is TRUE and S2 is FALSE
Explanation:
Short data type is a 16-bit signed
two's complement integer.
Minimum value is -32,768 (-2^15)
Maximum value is 32,767(inclusive)
(2^15 -1)
Default value is 0.
Example :
short s= 10000 , short r = -20000
Page: 27
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 14
Short data type can also be used
to save memory as byte data type.
A short is ____ times smaller than
an int. Fill in the blank.
a) 2
b) 3
c) 4
d) 8
Page: 28
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 14 (Solution)
Ans: a) 2
Explanation:
Short data type can also be used to
save memory as byte data type. A
short is 2 times smaller than an int.
int is of 32 bit whereas short is of 16
bit.
Page: 29
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 15
Long data type is a ________
signed two's complement integer.
Fill in the blank.
a) 8 bit
b) 16 bit
c) 32 bit
d) 64 bit
Page: 30
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 15 (Solution)
Ans: d) 64 bit
Explanation:
Long data type is a 64-bit signed
two's complement integer. This type
is used when a wider range than int
is needed.
Page: 31
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 16
Consider the following 2
statements(S1 and S2).
(S1) int data type is a 32-bit signed
two's complement integer.
(S2) Default value is 1.
Which of the following is correct.
a) S1 is TRUE and S2 is FALSE
b) S1 is FALSE and S2 is TRUE
c) Both S1 and S2 are TRUE
d) Both S1 and S2 are FALSE
Page: 32
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 16 (Solution)
Ans: a) S1 is TRUE and S2 is FALSE
Explanation:
Int data type is a 32-bit signed two's
complement integer.
Int is generally used as the default
data type for integral values unless
there is a concern about memory.
The default value is 0.
Example :
int a = 100000, int b = -200000
Page: 33
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 17
Which among the following data
types in JAVA has the largest
memory size?
a) int
b) short
c) byte
d) long
Page: 34
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 17 (Solution)
Ans: d) long
Explanation:
Long data type is a 64-bit signed
two's complement integer.
This type is used when a wider
range than int is needed. Short is 16
bit in size. Byte 8 bit and int is 32 bit
in size.
Page: 35
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 18
Consider the following 2
statements(S1 and S2).
(S1) float data type is a single-
precision 32-bit floating point.
(S2) double data type is a double-
precision 64-bit floating point.
Which of the following is correct.
a) S1 is TRUE and S2 is FALSE
b) S1 is FALSE and S2 is TRUE
c) Both S1 and S2 are TRUE
d) Both S1 and S2 are FALSE
Page: 36
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 18 (Solution)
Ans: c) Both S1 and S2 are TRUE
Explanation:
Float data type is a single-precision 32-bit
floating point.
Float is mainly used to save memory in
large arrays of floating point numbers.
Default value is 0.0f.
Example : float f1 = 234.5f
double data type is a double-precision 64-
bit floating point.
This data type is generally used as the
default data type for decimal values.
generally the default choice.
Default value is 0.0d.
Example : double d1 = 123.4
Page: 37
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 19
Consider the following 2
statements(S1 and S2).
(S1) boolean data type represents
one bit of information
(S2) There are only two possible
values of boolean data type : true
and false.
Which of the following is correct.
a) S1 is TRUE and S2 is FALSE
b) S1 is FALSE and S2 is TRUE
c) Both S1 and S2 are TRUE
d) Both S1 and S2 are FALSE
Page: 38
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 19 (Solution)
Ans: c) Both S1 and S2 are TRUE
Explanation:
boolean data type represents one bit
of information.
There are only two possible values :
true and false.
This data type is used for simple flags
that track true/false conditions.
Default value is false.
Example : boolean one = true
Page: 39
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 20
char data type in java is a single
__________ Unicode character.
Fill in the blank.
a) 8-bit
b) 16-bit
c) 32-bit
d) 64-bit
Page: 40
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 20 (Solution)
Ans: b) 16-bit
Explanation: char data type is a single
16-bit Unicode character.
Minimum value is 'u0000' (or 0).
Maximum value is 'uffff' (or 65,535
inclusive).
Char data type is used to store any
character.
Example . char letterA ='A'.
Unicode is a 16-bit character encoding
standard and is capable to represent
almost every character of well-known
languages of the world. Before Unicode,
there were multiple standards to
represent character encoding − ASCII -
for the United States.
Page: 41
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 21
What is the default value of
boolean data type in Java?
a) 1
b) 0
c) true
d) false
Page: 42
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 21 (Solution)
Ans: d) false
Explanation:
boolean data type represents one bit
of information.
There are only two possible values :
true and false.
This data type is used for simple
flags that track true/false conditions.
Default value is false.
Page: 43
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 22
What is the default value of a
reference variable in java?
a) Garbage Value
b) Null Value
c) Zero
d) One
Page: 44
MCQs Bank on Object Oriented Programming
Topic: Basic OOP concepts
MCQ No: 22 (Solution)
Ans: b) Null Value
Explanation:
Reference variable is used to point
object/values. Classes, interfaces,
arrays, enumerations, and,
annotations are reference types in
Java. In simple words, a reference
variable holds a reference to
information related to that variable. A
reference is an address that indicates
where an object's variables and
methods are stored.
Default value of any reference
variable is null.
Page: 45

More Related Content

PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
PPTX
Arrays in java
PPT
Exception Handling in JAVA
Multiple Choice Questions on JAVA (object oriented programming) bank 7 -- abs...
Multiple Choice Questions on JAVA (object oriented programming) bank 4 -- loops
Multiple Choice Questions on JAVA (object oriented programming) bank 6 -- inh...
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Multiple Choice Questions on JAVA (object oriented programming) bank 1 -- int...
Arrays in java
Exception Handling in JAVA

What's hot (20)

PPTX
Classpath
PPTX
Presentation on-exception-handling
PDF
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
PPT
Abstract class
PPT
C# Exceptions Handling
PPT
Decision making and loop in C#
PDF
FP 301 OOP FINAL PAPER JUNE 2013
PPSX
C# - Part 1
PDF
Dependency Injection
PDF
Java Fundamentals
PPTX
Polymorphism in java
PPT
Java OOP s concepts and buzzwords
PPTX
C# 101: Intro to Programming with C#
PPTX
Oops concept in c++ unit 3 -topic 4
PPT
Introduction To C#
PPTX
Functions in C
PPSX
Arrays in Java
PPT
Final keyword in java
PDF
Learn C# Programming - Decision Making & Loops
Classpath
Presentation on-exception-handling
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Abstract class
C# Exceptions Handling
Decision making and loop in C#
FP 301 OOP FINAL PAPER JUNE 2013
C# - Part 1
Dependency Injection
Java Fundamentals
Polymorphism in java
Java OOP s concepts and buzzwords
C# 101: Intro to Programming with C#
Oops concept in c++ unit 3 -topic 4
Introduction To C#
Functions in C
Arrays in Java
Final keyword in java
Learn C# Programming - Decision Making & Loops
Ad

Similar to Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- basic oop concepts (20)

DOCX
OOP Lab-manual btech in cse kerala technological university
PDF
Oop question-bank
PDF
Java MCQ Important Questions and Answers
DOCX
Mcs 024 assignment solution (2020-21)
PDF
Java Programming.pdf
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
PDF
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
PDF
OOM MCQ 2018
PDF
Introduction to Java Object Oriented Programming
PDF
Qb it1301
PDF
Core java interview faq
PPT
Unit 1- Basic concept of object-oriented-programming.ppt
PPT
Share Unit 1- Basic concept of object-oriented-programming.ppt
DOCX
Mcs 024 assignment solution (2020-21)
PDF
Unit 1 Core Java for Compter Science 3rd
PPTX
U1 JAVA.pptx
DOC
Faqs in java
PDF
Cs8392 oops 5 units notes
PDF
Probable questions for semester exam
PDF
Object oriented concepts
OOP Lab-manual btech in cse kerala technological university
Oop question-bank
Java MCQ Important Questions and Answers
Mcs 024 assignment solution (2020-21)
Java Programming.pdf
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
OOM MCQ 2018
Introduction to Java Object Oriented Programming
Qb it1301
Core java interview faq
Unit 1- Basic concept of object-oriented-programming.ppt
Share Unit 1- Basic concept of object-oriented-programming.ppt
Mcs 024 assignment solution (2020-21)
Unit 1 Core Java for Compter Science 3rd
U1 JAVA.pptx
Faqs in java
Cs8392 oops 5 units notes
Probable questions for semester exam
Object oriented concepts
Ad

More from Kuntal Bhowmick (20)

PDF
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
PPT
1. introduction to E-commerce
DOCX
Computer graphics question for exam solved
PDF
DBMS and Rdbms fundamental concepts
PDF
Java questions for interview
PDF
Java Interview Questions
PDF
Operating system Interview Questions
PDF
Computer Network Interview Questions
PDF
C interview questions
PDF
C question
PDF
Distributed operating systems cs704 a class test
DOCX
Cs291 assignment solution
DOCX
CS291(C Programming) assignment
PDF
C programming guide new
PDF
C lecture notes new
PDF
Shell script assignment 3
DOCX
Basic shell programs assignment 1
PDF
Basic shell programs assignment 1_solution_manual
DOCX
Shell programming assignment 2
PDF
Solution manual of shell programming assignment 2
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
1. introduction to E-commerce
Computer graphics question for exam solved
DBMS and Rdbms fundamental concepts
Java questions for interview
Java Interview Questions
Operating system Interview Questions
Computer Network Interview Questions
C interview questions
C question
Distributed operating systems cs704 a class test
Cs291 assignment solution
CS291(C Programming) assignment
C programming guide new
C lecture notes new
Shell script assignment 3
Basic shell programs assignment 1
Basic shell programs assignment 1_solution_manual
Shell programming assignment 2
Solution manual of shell programming assignment 2

Recently uploaded (20)

PDF
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
“Next-Gen AI: Trends Reshaping Our World”
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Glazing at Facade, functions, types of glazing
PDF
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...
PPTX
AgentX UiPath Community Webinar series - Delhi
PPTX
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
436813905-LNG-Process-Overview-Short.pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
PDF
ETO & MEO Certificate of Competency Questions and Answers
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
web development for engineering and engineering
PPTX
TE-AI-Unit VI notes using planning model
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
Arduino robotics embedded978-1-4302-3184-4.pdf
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
“Next-Gen AI: Trends Reshaping Our World”
Lesson 3_Tessellation.pptx finite Mathematics
Glazing at Facade, functions, types of glazing
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...
AgentX UiPath Community Webinar series - Delhi
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
Operating System & Kernel Study Guide-1 - converted.pdf
436813905-LNG-Process-Overview-Short.pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
ETO & MEO Certificate of Competency Questions and Answers
bas. eng. economics group 4 presentation 1.pptx
web development for engineering and engineering
TE-AI-Unit VI notes using planning model
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT

Multiple Choice Questions on JAVA (object oriented programming) bank 2 -- basic oop concepts

  • 1. MCQs BANK Page: 1 Object Oriented Programming Topic: Basic OOP concepts Instructions: This MCQs Bank contains question and solution on adjacent(even-odd) pages. First try to solve the MCQ by yourself, then look for the solution. Best viewed in “single page view” in PDF viewer. MCQs BANK No.: 2
  • 2. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 1 When you program for the Java platform, you write source code in _________ files. Fill in the blank. a) .class b) .cpp c) .java d) .html Page: 2
  • 3. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 1 (Solution) Ans: c) .java Explanation: When you program for the Java platform, you write source code in .java files and then compile them. Page: 3
  • 4. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 2 The java compiler checks your java code against the language's syntax rules, then writes out bytecodes in ________ files. Fill in the blank. a) .class b) .java c) .exe d) .obj Page: 4
  • 5. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 2 (Solution) Ans: a) .class Explanation: The compiler checks your code against the language's syntax rules, then writes out bytecodes in .class files. Page: 5
  • 6. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 3 Which of the following files the JVM(Java virtual machine) reads and interprets? a) .class b) .java c) .exe d) .obj Page: 6
  • 7. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 3 (Solution) Ans: a) .class Explanation: At run time, the JVM reads and interprets .class files and executes the program's instructions on the native hardware platform for which the JVM was written. Page: 7
  • 8. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 4 Identify the correct match combination. a) 1-x, 2-w, 3-z, 4-y b) 1-w, 2-x, 3-z, 4-y c) 1-x, 2-w, 3-y, 4-z d) 1-y, 2-w, 3-z, 4-x Page: 8 1) JVM w) Implicit memory management 2) Garbage collection x) Bytecode 3) Objects y) Pool of memory 4) Heap z) Instance variables
  • 9. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 4 (Solution) Ans: a) 1-x, 2-w, 3-z, 4-y Explanation: At run time, the JVM reads and interprets Bytecode ( in .class files) and executes the program's instructions on the native hardware platform for which the JVM was written. When your Java application creates an object instance at run time, the JVM automatically allocates memory space for that object from the heap, which is a pool of memory set aside for your program to use. The Java garbage collector runs in the background, keeping track of which objects the application no longer needs and reclaiming memory from them. This approach to memory handling is called implicit memory management because it doesn't require you to write any memory- handling code. Data field members of an object is called instance variables. Page: 9
  • 10. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 5 Which of the following process is used by objects for communication and coordination. a) method calling b) shared memory c) stack d) interpreter Page: 10
  • 11. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 5 (Solution) Ans: a) method calling Explanation: Objects talk to other objects by sending messages (method calls in the Java language). Page: 11
  • 12. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 6 ____________ access means the object's attributes are accessible only within the object itself. Fill in the blank. a) private b) public c) protected d) default Page: 12
  • 13. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 6 (Solution) Ans: a) private Explanation: On the Java platform, you can use access specifiers to vary the nature of object relationships from public to private. Public access is wide open, whereas private access means the object's attributes are accessible only within the object itself. Page: 13
  • 14. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 7 OOP introduces the concept of inheritance, where a subclass can "copy" the attributes and behavior of the super class. If some of those attributes or behaviors need to changed in subclass, then you need to __________ them. Fill in the blank. a) overload b) override c) delete d) integrate Page: 14
  • 15. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 7 (Solution) Ans: b) override Explanation: Overriding is a feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super-classes or parent classes. You only change what you need to change in order to create specialized objects. Page: 15
  • 16. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 8 Which of the following is a fundamental feature of object- oriented programming language? a) automatic garbage collection b) creating objects and manipulating objects c) platform independence d) all of the above Page: 16
  • 17. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 8 (Solution) Ans: b) creating objects and manipulating objects Explanation: Object-oriented programming is centered on creating objects, manipulating objects, and making objects work together. This allows you to create modular programs and reusable code. It is the fundamental feature of Object-oriented programming languages. Automatic garbage collection and platform independence are features specific to java(not present in all OOP language, such as C++). Page: 17
  • 18. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 9 Which of the following gives platform independence to java programs? a) Bytecode b) JVM c) Both (a) and (b) d) None of these Page: 18
  • 19. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 9 (Solution) Ans: c) Both (a) and (b) Explanation: JVM is needed in order to run Java programs. The programs are compiled into Java Virtual Machine code called bytecode. The bytecode is machine independent and is able to run on any machine that has a Java Virtual Machine. With Java, the program need only be compiled once, and the bytecode generated by the Java compiler can run on any platform. Page: 19
  • 20. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 10 ______________ is the capability for a program to perform several tasks simultaneously within a program. Fill in the blank. a) Polymorphism b) Multithreading c) Exception Handling d) Platform Independence Page: 20
  • 21. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 10 (Solution) Ans: b) Multithreading Explanation: Multithreading is the capability for a program to perform several tasks simultaneously within a program. In Java, multithreaded programming has been smoothly integrated into it, while in other languages, operating system-specific procedures have to be called in order to enable multithreading. Multithreading is a necessity in visual and network - programming. Page: 21
  • 22. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 11 Consider the following 2 statements(S1 and S2). (S1) byte data type is a 8-bit signed two's complement integer. (S2) Default value is 0. Which of the following is correct. a) S1 is TRUE and S2 is FALSE b) S1 is FALSE and S2 is TRUE c) Both S1 and S2 are TRUE d) Both S1 and S2 are FALSE Page: 22
  • 23. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 11 (Solution) Ans: c) Both S1 and S2 are TRUE Explanation: byte data type is a 8-bit signed two's complement integer. Minimum value is -128 (-2^7) Maximum value is 127 (inclusive)(2^7 -1) Default value is 0 Page: 23
  • 24. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 12 byte data type in java is used to save space in large arrays, mainly in place of integers, since a byte is ______ times smaller than an int. Fill in the blank. a) two b) three c) four d) eight Page: 24
  • 25. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 12 (Solution) Ans: c) four Explanation: Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int. Int data type is a 32-bit signed two's complement integer in java. Page: 25
  • 26. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 13 Consider the following 2 statements(S1 and S2). (S1) short data type is a 16-bit signed two's complement integer. (S2) Default value is 1. Which of the following is correct. a) S1 is TRUE and S2 is FALSE b) S1 is FALSE and S2 is TRUE c) Both S1 and S2 are TRUE d) Both S1 and S2 are FALSE Page: 26
  • 27. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 13 (Solution) Ans: a) S1 is TRUE and S2 is FALSE Explanation: Short data type is a 16-bit signed two's complement integer. Minimum value is -32,768 (-2^15) Maximum value is 32,767(inclusive) (2^15 -1) Default value is 0. Example : short s= 10000 , short r = -20000 Page: 27
  • 28. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 14 Short data type can also be used to save memory as byte data type. A short is ____ times smaller than an int. Fill in the blank. a) 2 b) 3 c) 4 d) 8 Page: 28
  • 29. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 14 (Solution) Ans: a) 2 Explanation: Short data type can also be used to save memory as byte data type. A short is 2 times smaller than an int. int is of 32 bit whereas short is of 16 bit. Page: 29
  • 30. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 15 Long data type is a ________ signed two's complement integer. Fill in the blank. a) 8 bit b) 16 bit c) 32 bit d) 64 bit Page: 30
  • 31. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 15 (Solution) Ans: d) 64 bit Explanation: Long data type is a 64-bit signed two's complement integer. This type is used when a wider range than int is needed. Page: 31
  • 32. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 16 Consider the following 2 statements(S1 and S2). (S1) int data type is a 32-bit signed two's complement integer. (S2) Default value is 1. Which of the following is correct. a) S1 is TRUE and S2 is FALSE b) S1 is FALSE and S2 is TRUE c) Both S1 and S2 are TRUE d) Both S1 and S2 are FALSE Page: 32
  • 33. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 16 (Solution) Ans: a) S1 is TRUE and S2 is FALSE Explanation: Int data type is a 32-bit signed two's complement integer. Int is generally used as the default data type for integral values unless there is a concern about memory. The default value is 0. Example : int a = 100000, int b = -200000 Page: 33
  • 34. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 17 Which among the following data types in JAVA has the largest memory size? a) int b) short c) byte d) long Page: 34
  • 35. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 17 (Solution) Ans: d) long Explanation: Long data type is a 64-bit signed two's complement integer. This type is used when a wider range than int is needed. Short is 16 bit in size. Byte 8 bit and int is 32 bit in size. Page: 35
  • 36. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 18 Consider the following 2 statements(S1 and S2). (S1) float data type is a single- precision 32-bit floating point. (S2) double data type is a double- precision 64-bit floating point. Which of the following is correct. a) S1 is TRUE and S2 is FALSE b) S1 is FALSE and S2 is TRUE c) Both S1 and S2 are TRUE d) Both S1 and S2 are FALSE Page: 36
  • 37. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 18 (Solution) Ans: c) Both S1 and S2 are TRUE Explanation: Float data type is a single-precision 32-bit floating point. Float is mainly used to save memory in large arrays of floating point numbers. Default value is 0.0f. Example : float f1 = 234.5f double data type is a double-precision 64- bit floating point. This data type is generally used as the default data type for decimal values. generally the default choice. Default value is 0.0d. Example : double d1 = 123.4 Page: 37
  • 38. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 19 Consider the following 2 statements(S1 and S2). (S1) boolean data type represents one bit of information (S2) There are only two possible values of boolean data type : true and false. Which of the following is correct. a) S1 is TRUE and S2 is FALSE b) S1 is FALSE and S2 is TRUE c) Both S1 and S2 are TRUE d) Both S1 and S2 are FALSE Page: 38
  • 39. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 19 (Solution) Ans: c) Both S1 and S2 are TRUE Explanation: boolean data type represents one bit of information. There are only two possible values : true and false. This data type is used for simple flags that track true/false conditions. Default value is false. Example : boolean one = true Page: 39
  • 40. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 20 char data type in java is a single __________ Unicode character. Fill in the blank. a) 8-bit b) 16-bit c) 32-bit d) 64-bit Page: 40
  • 41. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 20 (Solution) Ans: b) 16-bit Explanation: char data type is a single 16-bit Unicode character. Minimum value is 'u0000' (or 0). Maximum value is 'uffff' (or 65,535 inclusive). Char data type is used to store any character. Example . char letterA ='A'. Unicode is a 16-bit character encoding standard and is capable to represent almost every character of well-known languages of the world. Before Unicode, there were multiple standards to represent character encoding − ASCII - for the United States. Page: 41
  • 42. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 21 What is the default value of boolean data type in Java? a) 1 b) 0 c) true d) false Page: 42
  • 43. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 21 (Solution) Ans: d) false Explanation: boolean data type represents one bit of information. There are only two possible values : true and false. This data type is used for simple flags that track true/false conditions. Default value is false. Page: 43
  • 44. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 22 What is the default value of a reference variable in java? a) Garbage Value b) Null Value c) Zero d) One Page: 44
  • 45. MCQs Bank on Object Oriented Programming Topic: Basic OOP concepts MCQ No: 22 (Solution) Ans: b) Null Value Explanation: Reference variable is used to point object/values. Classes, interfaces, arrays, enumerations, and, annotations are reference types in Java. In simple words, a reference variable holds a reference to information related to that variable. A reference is an address that indicates where an object's variables and methods are stored. Default value of any reference variable is null. Page: 45