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

What's hot (20)

PPTX
Asp.net MVC training session
Hrichi Mohamed
 
PDF
Java ArrayList Tutorial | Edureka
Edureka!
 
PPT
Core java concepts
Ram132
 
PDF
Java 8 Stream API. A different way to process collections.
David Gómez García
 
PDF
Java 8 Lambda Expressions
Scott Leberknight
 
PPTX
Methods in java
chauhankapil
 
PPT
JavaScript Objects
Reem Alattas
 
PPTX
OOP Introduction with java programming language
Md.Al-imran Roton
 
PPTX
Java Server Pages
Kasun Madusanke
 
PDF
Java 8 Lambda Built-in Functional Interfaces
Ganesh Samarthyam
 
PPT
L11 array list
teach4uin
 
PPT
11 constructors in derived classes
Docent Education
 
PDF
Introduction to Java Programming
Ravi Kant Sahu
 
PPT
C++ Pointers And References
verisan
 
PPTX
Presentation1
Anand Grewal
 
PPTX
Java Beans
Ankit Desai
 
PPTX
Jquery Complete Presentation along with Javascript Basics
EPAM Systems
 
PPTX
Angular js PPT
Imtiyaz Ahmad Khan
 
PPT
Jdbc ppt
Vikas Jagtap
 
PPTX
Java awt (abstract window toolkit)
Elizabeth alexander
 
Asp.net MVC training session
Hrichi Mohamed
 
Java ArrayList Tutorial | Edureka
Edureka!
 
Core java concepts
Ram132
 
Java 8 Stream API. A different way to process collections.
David Gómez García
 
Java 8 Lambda Expressions
Scott Leberknight
 
Methods in java
chauhankapil
 
JavaScript Objects
Reem Alattas
 
OOP Introduction with java programming language
Md.Al-imran Roton
 
Java Server Pages
Kasun Madusanke
 
Java 8 Lambda Built-in Functional Interfaces
Ganesh Samarthyam
 
L11 array list
teach4uin
 
11 constructors in derived classes
Docent Education
 
Introduction to Java Programming
Ravi Kant Sahu
 
C++ Pointers And References
verisan
 
Presentation1
Anand Grewal
 
Java Beans
Ankit Desai
 
Jquery Complete Presentation along with Javascript Basics
EPAM Systems
 
Angular js PPT
Imtiyaz Ahmad Khan
 
Jdbc ppt
Vikas Jagtap
 
Java awt (abstract window toolkit)
Elizabeth alexander
 

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

PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Kuntal Bhowmick
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Kuntal Bhowmick
 
PDF
50 common web developer interview questions [2020 updated] [www.full stack....
Alex Ershov
 
PDF
Learning to Spot and Refactor Inconsistent Method Names
Dongsun Kim
 
PDF
XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...
Alessandro Confetti
 
PPTX
ASE2023_SCPatcher_Presentation_V5.pptx
jzyNick
 
PPTX
Migrating from OpenGL to Vulkan
Mark Kilgard
 
PPTX
OpenCV+Android.pptx
Vishwas459764
 
PDF
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Kuntal Bhowmick
 
PDF
Top 40 Javascript Interview Questions and Answers.pdf
paldibya712
 
PDF
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
Artur Skowroński
 
PPTX
OpenCV @ Droidcon 2012
Wingston
 
DOCX
Bt0074 oop with java
smumbahelp
 
PDF
Portfolio
Ivan Khomyakov
 
PDF
The Little Unicorn That Could
PVS-Studio
 
PPTX
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
NicheTech Com. Solutions Pvt. Ltd.
 
PDF
alphablues - ML applied to text and image in chat bots
André Karpištšenko
 
PPTX
Don't Call It a Comeback: Attribute Grammars for Big Data Visualization
Leo Meyerovich
 
PDF
Intro to c# (vs. objective c and java)
Wes Yanaga
 
PDF
Intro to c# (vs. objective c and java)
John Smith
 
Multiple Choice Questions on JAVA (object oriented programming) bank 3 -- cla...
Kuntal Bhowmick
 
Multiple Choice Questions on JAVA (object oriented programming) bank 5 -- mem...
Kuntal Bhowmick
 
50 common web developer interview questions [2020 updated] [www.full stack....
Alex Ershov
 
Learning to Spot and Refactor Inconsistent Method Names
Dongsun Kim
 
XConf 2022 - Code As Data: How data insights on legacy codebases can fill the...
Alessandro Confetti
 
ASE2023_SCPatcher_Presentation_V5.pptx
jzyNick
 
Migrating from OpenGL to Vulkan
Mark Kilgard
 
OpenCV+Android.pptx
Vishwas459764
 
Multiple Choice Questions on JAVA (object oriented programming) bank 8 -- int...
Kuntal Bhowmick
 
Top 40 Javascript Interview Questions and Answers.pdf
paldibya712
 
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
Artur Skowroński
 
OpenCV @ Droidcon 2012
Wingston
 
Bt0074 oop with java
smumbahelp
 
Portfolio
Ivan Khomyakov
 
The Little Unicorn That Could
PVS-Studio
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
NicheTech Com. Solutions Pvt. Ltd.
 
alphablues - ML applied to text and image in chat bots
André Karpištšenko
 
Don't Call It a Comeback: Attribute Grammars for Big Data Visualization
Leo Meyerovich
 
Intro to c# (vs. objective c and java)
Wes Yanaga
 
Intro to c# (vs. objective c and java)
John Smith
 
Ad

More from Kuntal Bhowmick (20)

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

Recently uploaded (20)

PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
MRRS Strength and Durability of Concrete
CivilMythili
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
Design Thinking basics for Engineers.pdf
CMR University
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 

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