(1) A class constructor method __________ . (a) must have the same name as the c
ID: 3817082 • Letter: #
Question
(1) A class constructor method __________ .
(a) must have the same name as the class it is declared within
(b) is used to create objects
(c) may be declared private
(d) both (a) and (b) above
(e) (a) , (b) and (c) above
2. Consider the class definition that is shown.
public class MyClass
{
public MyClass() { // code // }
// more code statements . . .
}
To instantiate an object of MyClass , what would you write?
(a) MyClass mc = new MyClass();
(b) MyClass mc = MyClass();
(c) MyClass mc = MyClass;
(d) MyClass mc = new MyClass;
(e) The constructor of MyClass should be defined as follows.
public void MyClass() { // code // }
For each of the following exercise, match the description on the left with an item on the right. Use each selection on the right only once.
_____ (3) one of four key words used in (a) mutator
object - oriented programming
_____ (4) an instance of a class (b) inheritance
_____ (5) capability of methods to exhibit (c) polymorphism
different behavior
_____ (6) allows a class to use the properties and (d) object
methods of another class
_____ (7) used to hide certain details and only show (e) void
the essential features of the object
_____ (8) another term for the " get " method (f) abstraction
_____ (9) a method that modifies the data of (g) encapsulation
an object
_____ (10) one of the four key words for a method (h) accessor
Explanation / Answer
Answer-1. (e) because we know that constructer have same name as the class it is declared within,constructer is also used for creating object and sometime it can be declared as private.
Answer -2. (a)
because the syntax for creating an object is :
classname objectname=new classname();
so as in question classname=MyClass objectname=mc
so that MyClass mc=new MyClass(); is correct answer.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.