ANSWER KEY (8) - 70 Que

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Chapter 8 Classes and Objects in Java

Unit Test 2018 (Std. 12th E.M.)


STUDENT’S NAME : ____________________________________DIV._________ ROLL NO.: ______

Textbook Exercise

(1) Which of the following defines attributes and methods?


(A) Class (B) Object (C) Instance (D) Variable
(2) Which of the following keyword is used to declare Class variables 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) dot (.) (B) new (C) colon (:) (D) assignment (=)
(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 these
(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 these
(6) Which method is invoked automatically with creation of an object?
(A) Instance method (B) Constructor
(C) Class method (D) All of these
(7) Which of the following is the keyword used to refer a superclass constructor in subclass
constructor?
(A) extends (B) super
(C) name of the superclass (D) new
(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
(9) Which of the following is accessible by instance methods?
(A) Only instance variables (B) Only class variables
(C) Both (A) and (B) (D) None of these
(10) When methods in the superclass and subclass have same name and signature, what are
they called ?
(A) Overloaded methods (B) Overridden methods
(C) Inherited methods (D) All of these
12 (General) | March – 2015
(11) Which method of Java class is used if we want to allow other methods to modify the data
value?
(A) Set or Setter (B) Get or Getter
(C) Both (A) and (B) (D) None of these
(12) In Java class, from the followings, which key word is used to call the constructor of super
class in the constructor of sub class ?
(A) Extends (B) Super
(C) Name of the super class (D) New

Page 1
(13) In Java which method is invoked automatically with creation of an object ?
(A) Instance method (B) Constructor
(C) Class method (D) All of these
(14) How does the Constructor differ from general method in Java ?
(A) It must have the same name as class.
(B) It does not have return type.
(C) It can’t be invoked explicitly in the program.
(D) All of these
(15) How many levels of visibility are used to protect a method or variable from such reference
in Java?
(A) 1 (B) 2 (C) 3 (D) 4
(16) From which of the following operators can we access instance variables and instance
methods?
(A) , (Comma) (B) . (Full stop) (C) : (Colon) (D) ; (Semi colon)
(17) In Java class, in which step a new keyword is used to create the object by allocating
memory ?
(A) Declaration (B) Instantiation (C) Initialization (D) All of these
(18) In Java, by which component is the class generally made up of ?
(A) Attributes (B) Behaviour (C) Both (A) and (B) (D) Variable
(19) How do you identify the variable which is define with in a class, out-side any method with
the static key word in Java ?
(A) Local variables (B) Instance variables
(C) Class variables (D) None of these
(20) In Java, which of the following defines attributes and methods?
(A) Class (B) Object (C) Instance (D) Variable
12 (Science) | March – 2015

(21) Java class is generally made up of which components?


(A) behaviour, variable (B) attributes, behaviour
(C) name, attributes (D) name, variable
(22) A variable declared using class type can store what to an object?
(A) relation (B) root (C) rate (D) reference
(23) In Object-oriented programming languages, creating an object is also called as what?
(A) Object instantiation (B) Oriented installation
(C) Installation (D) Project installation
(24) Whenever two classes have a ‘is-a’ relationship, what is used?
(A) Instant (B) Relations (C) Inheritance (D) Invalue
(25) Which class inherits all instance variables and methods from super class and it may have
its own added variables and methods ?
(A) Out class (B) Super class (C) In class (D) Sub class
(26) Which keyword is used to call the constructor of super class in the constructor of sub class?
(A) super (B) void (C) sub (D) class

(27) A sub class can be derived from which class?


(A) over class (B) super class (C) main class (D) own class

Page 2
(28) Instance variables and instance methods are accessed via objects. They can be referred by
using which operator?
(A) // (B) dot (.) (C) $ (D) #
(29) Which type of variables are defined within a class but outside any method?
(A) Class variable (B) Empty variable
(C) Local variable (D) Instance variable
(30) In Java, we can have different methods that have the same name but a different signature
is also called as what ?
(A) Method overloading (B) Variable overloading
(C) Class overloading (D) Signature overloading
(31) To provide an user defined no-argument constructors, which of the following command is
used ?
(A) school (float I, float j); (B) school (int i);
(C) school ( ) { }; (D) school { } ( );
(32) Who established a “has – a” relationship between class?
(A) Composition and Aggregation (B) Method and Object
(C) Relation and Method (D) Inheritance and Aggregation
(33) Java have a ..... that looks for unused objects and reclaims the memory that those objects
are using.
(A) reclaim collector (B) unused collector
(C) memory collector (D) garbage collector
(34) The word polymorphism means what?
(A) Many forms (B) Virtual forms (C) One form (D) User forms
(35) Which of the following is syntax of package?
(A) package {Name} (B) package (Name);
(C) package <Package Name>; (D) package [Variable name];
(36) Which of the following is special kind of method that is invoked when a new object is
created?
(A) Common class (B) Super class (C) Composition (D) Constructors
(37) Which are the for P’s used in the four levels of visibility to provide necessary protection?
(A) Process, Private, Protected, Public (B) Public, Package, Protected, Private
(C) Public, Package, Protected, Process (D) Private, Package, Protected, Public
(38) Highest level of protection can be achieved by using which protection level?
(A) Private (B) Public (C) Protected (D) Package
(39) If we wan to follow other methods to read only the data value ..... method can be used.
(A) setter (B) updater (C) reader (D) getter
(40) Who allows us to build new class with added capabilities by extending existing class?
(A) Inheritage (B) Instant (C) Inheritance (D) Instance
12 (General) | March – 2016
(41) In Java, a class is defined using which keyword?
(A) class (B) public (C) static (D) main
(42) Which steps are followed to create an object from a class?
(A) Declaration (B) Instantiation (C) Initialization (D) All of these
(43) In Object oriented programming (OOP) languages what is known for creating an object?
(A) Object Instantiation (B) Object creation
(C) Object Making (D) None of these

Page 3
(44) Variables defined inside methods or blocks are known as which type of variable?
(A) Local variables (B) Instance variables
(C) Class variables (D) Block variables
(45) Which word means “many forms”, different forms of methods with same name in Java?
(A) Inheritance (B) Polymorphism (C) Aggregation (D) Composition
(46) In Java, from the following which visibility modifiers are used to protect a method or
variable from another class ?
(A) Public (B) Package
(C) Protected and Private (D) All of these
(47) In Java class, which operator is used to access instance variable and instance method via
object ?
(A) : (colon) (B) ; (semicolon) (C). (dot) (D) , (comma)
(48) If we want to allow data to be used by others we write which type of method in Java?
(A) getter (B) setter (C) main (D) void
(49) In Java, which type of visibility modifier level of protection is used to allow the access only
to sub classes or to share with the methods declared as “friend” ?
(A) Public (B) Package (C) Protected (D) Private
(50) Highest level of protection can be achieved by using which visibility modifiers protection
level in Java?
(A) Public (B) Package (C) Protected (D) Private
12 (Science) | March – 2016
(51) In Java, which of the following consist of attributes and methods?
(A) Instance (B) Variables (C) Object (D) Class
(52) Which keyword is used to create the object which allocates memory in Java?
(A) new (B) add (C) int (D) create
(53) In Java, what is called to initialize the newly created object?
(A) Classes (B) Reference variable
(C) Syntax variable (D) Constructor
(54) All instances of class allocated memory in data structure in Java and it is known as which
of the following ?
(A) Directory (B) File (C) Heap (D) Buffer
(55) Instance variables and instance methods in Java are accessed via objects and they can be
referred by using which operator?
(A) Arithmetic operator (+) (B) Dot operator (.)
(C) Assignment operator (=) (D) Colon operator (:)
(56) Values of class variables are stored where in Java?
(A) Class (B) File (C) Instance (D) Dir
(57) In Java, variables defined inside methods or blocks are called which variables?
(A) Global variable (B) Instance variable
(C) Class variable (D) Local variable
(58) In Java, different forms of methods with same name is known as which of the following?
(A) Composition (B) Polymorphism (C) Mutators (D) Inheritance
(59) Which access modifiers can be used before the type of variable or method in Java?
(A) Public (B) Protected (C) Private (D) All of these
(60) By using which access modifier, allows access only to subclass or to share with the
methods declared as “friend” in Java ?
(A) Package (B) Protected (C) Private (D) Public
Page 4
(61) In Java, if we want protected data to be modified by others then which methods are to be
written?
(A) Accessor (B) Getter (C) Mutator (D) Both (A) and (B)
(62) In Java, if we want to allow other methods to read only data value, if our program we
should use which method ?
(A) Setter (B) Getter (C) Mutator (D) Both (A) and (B)
(63) In Java, which of the following allows us to build new class with added capabilities by
extending existing class?
(A) Aggregation (B) Polymorphism
(C) Composition (D) Inheritance
(64) Inheritance model consist of which type of relationship between two classes in Java?
(A) is – a (B) has – a (C) have – a (D) was – a
(65) In Java, a sub class inherits all instance variables and methods from which class?
(A) Derived class (B) Instance class (C) Super class (D) Child class
(66) Composition and Aggregation establish which type of relationship between classes in Java?
(A) has - a (B) is – a (C) was – a (D) as – a
(67) In Java, ‘Visibility Modifiers’ – ‘Protected’ members are available as which members in the
inherited subclass?
(A) Object (B) Public (C) Instance (D) Private
(68) In Java, while using inheritance – “Child class” can be referred to as which of the following?
(A) Sub class (B) Derived class (C) Extended class (D) All of these
(69) Which of the following is the keyword used to refer a super class constructor in sub class
constructor?
(A) Name of subclass (B) New
(C) Super (D) Extends
(70) In Java, which variable are defined with in a class, outside any method with static
keyword?
(A) Global variable (B) Class variable
(C) Instance variable (D) Local variable

Page 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy