CH NO. 8: CLASSES AND OBJECTS IN JAVA (Made by me)
(1)
Which of the following defines attributes and methods?
(a) Class (b) Object (c) Function (d)
Variable
(2)
Which of the following keyword is used to declare
Class variable and class methods?
(a) static (b) private (c) public (d)
package
(3)
Which of the following operator creates an object and
returns its reference?
(a) assign (b)
static (c) new (d)
create
(4)
Which of the
following method can be called without creating an instance of a class?
(a) Instance method (b) Class method (c) Constructor method (d)
All of the above
(5)
Which of the following refers more than one method
having same name but different parameters?
(a) Overloaded
methods (b)
Overridden methods
(c) Duplicate methods (d) All of the above
(c) Duplicate methods (d) All of the above
(6)
Which method is invoked automatically with common of
an object?
(a) Instance method (b) Constructor (c) Class method (d)
All of the above
(7)
Which of the following is the keyword used to refer a
super class constructor in subclass constructor?
(a) extends (b) super (c) new (d)
public
(8)
Which of the following is used to invoke an instance
method in Java?
(a) The name of the object, colon(;) and the name of
the method.
(b) The name of the object, dot(.) and the name of the method.
(c) The name of the class, colon(;) and the name of the method.
(d) The name of the class, dot(.) and the name of the method.
(b) The name of the object, dot(.) and the name of the method.
(c) The name of the class, colon(;) and the name of the method.
(d) The name of the class, dot(.) and the name of the method.
(9)
Which of the following is accessible by instance
methods?
(a) Only instance variables (b) Only class variables
(c) Both Instance variables and class variables (d) All of the above
(c) Both Instance variables and class variables (d) All of the above
(10)
When methods in the super class and sub class have
same name and signature, what are they called?
(a) Overloaded methods (b) Overridden methods
(c) Inherited methods (d) All of the above
(c) Inherited methods (d) All of the above
(11)
A ……………… contains data and program code.
(a) object (b) class (c) function (d)
constructor
(12)
A ……………… can also be considered as a design for the
real life objects.
(a) object (b) class (c) function (d)
constructor
(13)
The ……………… shares the common characteristics of a
class.
(a) object (b) property (c) function (d)
variable
(14)
Every class in Java is generally made up of ……………………
components.
(a) two (b) three (c) four (d)
five
(15)
…………………… are defined by variables in a class.
(a) Attributes (b) Methods (c)
Objects (d) All of the
above
(16)
…………………… are used to access or modify attributes of a
class.
(a) Attributes (b) Methods (c) Objects (d)
All of the above
(17)
A variable name of type class is declared with syntax
<class name> <variable name> is termed as ……………………
(a) Declaration (b) Instantiation (c) Initialization (d)
Construction
(18)
Keyword new is used to create the object by allocating
memory is termed as ……………………
(a) Declaration (b) Instantiation (c) Initialization (d) Construction
(19)
Constructor is called to initialize the newly created
object is termed as ……………………
(a) Declaration (b)
Instantiation (c) Initialization (d) Construction
(20)
The syntax of the class object declaration is :
(a) <class name> <method> <object
name>; (b) <class name> <object name>;
(c) <method> <class name> <object name>; (d) None of these
(c) <method> <class name> <object name>; (d) None of these
(21)
Reference is the …………………… of the memory location where
the object is stored.
(a) pointer (b) address (c) operator (d)
citation
(22)
The objects live in the special portion of the memory
called the ……………………
(a) mass (b) heap (c) stack (d)
mound
(23)
When an object is created to allocating memory, a
special method ………………… is executed.
(a) creator (b)
inventor (c) constructor (d) designer
(24)
Which of the following is correct object created as
per Java?
(a) String
str=new String(“I Love India”); (b)
Room r=new Room( )
(c) Both (a) & (b) (d) None of these
(c) Both (a) & (b) (d) None of these
(25)
In object-oriented programming (OOP) languages,
creating an object is called ……………………
(a) Declaration (b) Instantiation (c) Initialization (d) Construction
(26)
Class is an …………………… representation of an object.
(a) abstract (b) intangible (c) elusive (d)
obscure
(27)
All instances of class are allocated memory in data
structure called ……………………
(a) mass (b) heap (c) stack (d)
mound
(28)
Instance variables and instance methods are accessed
via ……………………
(a) attributes (b)
methods (c) operators (d) objects
(29)
The syntax for accessing methods or variables of a
class is:
(a) <class name>.<instance variable or
method>
(b) <object reference>.<instance variable or method>
(c) <class reference>.<object reference>
(d) None of these
(b) <object reference>.<instance variable or method>
(c) <class reference>.<object reference>
(d) None of these
(30)
When the …………………… variables are referred within the
methods of the same class, there is not need to use dot(.) operator.
(a)
Instance (b) class (c) constructor (d) All of the above
(31)
The new keyword returns a ……………… to an object that
represents an instance of the class.
(a) instance (b) reference (c) address (d)
variable
(32)
Instance variables and instance methods are access via
……………………
(a) classes (b)
variables (c) abstract (d) objects
(33)
Instance variables and instance methods can be
accessed using …………………… operator.
(a) dot(.) (b) dollar($) (c) modulus (%) (d)
comma (,)
(34)
Which of the following statement(s) is/ are incorrect?
(a) Every object is created using new keyword.
(b) Every object has its own instance variables
occupying different spaces in memory.
(c) Values
of instance variables are stored in class itself.
(d) The class variable should be allocated the memory
only once per class.
(35)
The …………………… variables can be accessed without
creating an instance of a class.
(a) static (b) instance (c) global (d)
local
(36)
Which of the following statement(s) is/ are incorrect?
(a) Class variables and class methods can be accessed
using a class name or reference variable.
(b) Instance variables and instance methods can’t be
accessed from class methods.
(c) Class methods do not belong to any object.
(d) Instance
variables do not belong to any object.
(37)
Variables defined inside methods or blocks are called
…………………… variables.
(a) static (b)
instance (c) class (d) local
(38)
The …………………… variables are defined within a class but
outside any method.
(a) static (b) instance (c) global (d)
local
(39)
The …………………… variables are defined within a class,
outside any method, with the static
keyword.
(a) local (b)
instance (c) global (d) class
(40)
Which of the following statement(s) is/ are incorrect?
(a) Instance variables are allocated memory from heap
area.
(b) Instance variables are initialized by default
values.
(c) Class variables shares the memory with all its
objects.
(d) Instance
variables are allocated memory only once per class & shared by all its
objects.
(41)
The word polymorphism means ……………………
(a) many things (b)
single thing (c) many forms (d) single form
(42)
Java provides the different forms of methods with same
name, which is termed as ……………
(a) Data Hiding (b)
Data Abstraction (c) Encapsulation (d)
Polymorphism
(43)
When a single method is having different signatures
(syntaxes) it is termed as ……………………
(a) method unloading (b) method overloading
(c) method reloading (d) method loading
(c) method reloading (d) method loading
(44)
Java facilitates to create methods with same name but
different parameters, this facility is termed as ……………………
(a) method unloading (b) method overloading
(c) method reloading (d) method loading
(c) method reloading (d) method loading
(45)
…………………… is a special kind of method that is invoked
when a new object is created.
(a) Local (b) Constructor (c) Destructor (d)
Global
(46)
Which of the following statement(s) is/are correct in
context of Constructors in Java?
(a) Constructors must have the same name as of the
object names.
(b) Constructors
do not have any return type.
(c) Constructors are invoked explicitly anywhere in
the program.
(d) Constructors are local methods.
(47)
Which of the following statement(s) is/are correct in
context of Constructors in Java?
(a)
Constructors must have the same name as class name.
(b) Constructors return the class type.
(c) Constructors cannot be overloaded.
(d) Constructors are global methods.
(48)
Which of the following statement(s) is/are correct in
context of Constructors in Java?
(a)
Constructors can be overloaded.
(b) Constructors return the class type.
(c) Constructors are invoked explicitly anywhere in
the program.
(d) Constructors are global methods.
(49)
If the name of class is Room in java, which of the
following is the default constructor?
(a) Room( ) (b)
Room(float l, float w)
(c) static void Room( ) (d) double Room(float l, float w)
(c) static void Room( ) (d) double Room(float l, float w)
(50)
If the name of class is Room in java, which of the
following is the constructor with arguments?
(a) Room( ) (b) Room(float l, float w)
(c) static void Room( ) (d) double Room(float l, float w)
(c) static void Room( ) (d) double Room(float l, float w)
(51)
Match the table of Access Modifier with its
visibility.
Access Modifier Visibility
1)
public : i) Ã Ã
2)
package : ii) widest
3)
protected : iii) narrowest
4)
private : iv) Ã Ã Ã
(a) 1-ii, 2-iv, 3-i, 4-iii (b)
1-ii, 2-iv, 3-i, 4-iii (c) 1-iii,
2-iv, 3-ii, 4-i (d) 1-iv, 2-iii,
3-ii, 4-i
(52)
…………………… modifiers are also known as visibility
modifiers.
(a) Access (b) Control (c) Display (d)
Program
(53)
…………………… modifiers are about controlling visibility in
Java.
(a) Access (b) Control (c) Display (d)
Program
(54)
There are …………………… levels of visibility to provide
necessary protection.
(a) two (b)
three (c) four (d) five
(55)
…………………… is used to organize classes.
(a) Public (b)
Protected (c) Private (d) Package
(56)
Which of the following statement is incorrect?
(a) The Four P’s of protection are public, package,
protected and private.
(b) public, protected and private are used before the
type of variable or method.
© When a file does not have package statement, the
class defined in the file are place din default package.
(d) protected
visibility is the default mode.
(57)
If the user wants to make visible the methods or
variables of class to outside that class, those variables and methods have to
be …………………… visibility mode.
(a) public (b) protected (c) private (d)
package
(58)
The …………………… variables and methods are visible
anywhere and thus can be accessed from other source files and packages also.
(a) public (b) protected (c) private (d)
package
(59)
The default of visibility protection is ……………………
access modifier.
(a) public (b) protected (c) private (d)
package
(60)
The source file without package statement is
considered as a package by ……………………
(a) loaded (b) default (c) overloaded (d)
user defined
(61)
The level of protection of …………………… is used to allow
the access only to subclasses or to
share with the methods declared as “friend”.
(a) public (b) protected (c) private (d)
package
(62)
Highest level of protection can be achieved by using
the …………………… protection level.
(a) public (b)
protected (c) private (d) package
(63)
The …………………… methods and variables are directly
accessible only by the methods defined within a class.
(a) public (b)
protected (c) private (d) package
(64)
The variables and methods of class cannot be seen in
other class, when the visibility protection level is used as ……………………
(a) public (b)
protected (c) private (d) package
(65)
The …………………… protection level provides data
encapsulation, data hiding, limiting its manipulation.
(a) public (b)
protected (c) private (d) package
(66)
The best way to provide data encapsulation is to make
as much data as …………………… as possible.
(a) public (b)
protected (c) private (d) package
(67)
To access the private variables from another class :
(a) It can be directly accessed from other class.
(b) It can
be made available indirectly by the accessible methods.
(c) It can be made available directly by the private
methods.
(d) It is not possible to access the private members
from another class.
(68)
When the user restricts access to date by declaring
them as private, the purpose is to proect them from getting directly accessed
or modified by methods of other class. If user want to allow such data to be
used by others, then the user should write …………………… methods.
(a) restricted (b)
mutator (c) accessor (d) processor
(69)
If the user wants to allow the restricted data to be modified
by others, then user should write the ……………………
methods.
(a) restricted (b) mutator (c) accessor (d)
processor
(70)
The accessor methods are also termed as ……………………
(a) getter (b) setter (c) putter (d)
provider
(71)
The mutator methods are also termed as ……………………
(a) getter (b) setter (c) putter (d)
provider
(72)
If the user wants to allow other methods to read only
the data value, the user should use …………………… methods.
(a) getter (b) setter (c) putter (d)
provider
(73)
If the user wants to allow other methods to modify the
data value, the user should use …………………… methods.
(a) getter (b) setter (c) putter (d)
provider
(74)
The use of …………………… method(s) will prevent the
variables from getting directly accessed and modified by other class.
(a) accessor (b)
mutator (c) Both (a) & (b) (d) None of these
(75)
…………………… models ‘is-a’ relationship between two
classes.
(a) Aggregation (b)
Composition (c) Inheritance (d) None of these
No comments
Post your comments