Professional Documents
Culture Documents
(1 point)
When you think of object-oriented manner, everything is an , and every object is a member of a
.
Blank 1:
Blank 2:
Question 2 (1 point)
Object
a
Class
b
Method
c
Variables
d
Question 3 (1 point)
__ can be defined as a template/blueprint that describes the behavior/state that the object of its
type support.
Method
a
Class
b
Object
c
Variables
d
Question 4 (1 point)
Accessor Methods
a
Object Instantiation
b
Instance Variables
c
Mutator Methods
d
Question 5 (1 point)
Mutator Methods
a
Abstract Methods
b
Accessor Methods
c
Constructor
d
Question 6 (1 point)
double ratePerHour;
int numOfHours;
empName = name;
String getName() {
return empName;
Based on the given codes above, which of the following method is a(n) constructor?
setName
a
getName
b
Employee
c
None of the above.
d
Question 7 (1 point)
Which of the following DOES NOT describe a constructor in a Java class?
public Employee() {
Based on the given codes above, which of the following constructor declaration is wrong?
public Employee()
a
public Employee(String employee, double pay)
b
public void Employee(String employee, double pay)
c
None. All are correct.
d
Question 9 (1 point)
Local
a
Instance
b
Class/Static
c
None of the above.
d
Question 11 (1 point)
A type of variable which is rarely used other than being declared as constant.
Local
a
Instance
b
Class/Static
c
None of the above.
d
Question 12 (1 point)
Data Overloading
a
Data Hiding
b
Data Encapsulation
c
Data Hidding
d
Question 13 (1 point)
Methods
a
Variables
b
Classes
c
Objects
d
Question 15 (1 point)
public class Test {
public void DisplayAge() {
int age = 10;
age += 5;
System.out.println("Age: " +age);
}
public static void main(String args[]) {
Test test = new Test();
test.DisplayAge();
}
}
In the code above, what type of variable age is?
Parameter
a
Instance Variable
b
Local Variable
c
Class Variable
d
Question 16 (1 point)
public class Test {
private int age;
public Test(int setAge) {
age = setAge;
}
public void DisplayAge() {
age += 5;
System.out.println("Age: " +age);
}
public static void main(String args[]) {
Test test = new Test(10);
test.DisplayAge();
}
}
In the above code, what type of variable age is?
Class Variable
a
Local Variable
b
Parameter
c
Instance Variable
d
Question 17 (1 point)
class Encapsulation {
this.name=name;
this.address=address;
package PackB;
import PackA.ModifSample;
Hello!
a
Error - both mutator and accessor of class ModifSample are only visible within PackA
b and subclasses
Error - both mutator and accessor of class ModifSample are only visible within its
c class
Error - both mutator and accessor of class ModifSample are only visible within PackA
d
Question 19 (1 point)
class AreaOfCircle {
Determine the output of the given codes above, and choose the BEST answer.
Area: 2070.58
a
Error: Private variables are only visible within a class.
b
Error: Variables declared as final cannot be changed.
c
Error: Class AreaOfCircle must have a valid access modifier.
d
Question 20 (1 point)
Encapsulation
a
Abstraction
b
Polymorphism
c
Inheritance
d
Question 21 (1 point)
A way to discover which of the two classes is the base class and which is the subclass is
________.
child class
a
subclass
b
derived class
c
parent class
d
Question 40 (1 point)
constructor
a
public
b
static
c
private
d
Question 41 (1 point)
Which among the following best describes polymorphism?
If same message is passed to objects of several different classes and all of those can respond in a
different way, what is this feature called?
Inheritance
a
Polymorphism
b
Overloading
c
Overriding
d
Question 43 (1 point)
In Polymorphism, __________ means there are several methods present in a class having
thesame name but different types/order/number of parameters.
Method Clustering
a
Method Overriding
b
Method Overloading
c
Method Calling
d
Question 44 (1 point)
Method Overriding
a
Method Clustering
b
Method Calling
c
Method Overloading
d
Question 45 (1 point)
True or False:
In Method Overriding, Java knows which method to invoke by checking the method signatures
during compile time.
True
False
Question 46 (1 point)
Tru or False:
In Method Overloading, Java knows what method to invoke depending on what object has been
instantiated.
True
False
Question 47 (1 point)
What polymorphism type is being implement on the following code segement:
class Employee {
public double GrossPay(double rate, double hrs) {
return (rate*hrs);
}
public double GrossPay(double rate, double hrs, double bonus, double incentive) {
return ((rate*hrs)+(bonus+incentive));
}
}
class Employee {
public double GrossPay(double rate, double hrs) {
return (rate*hrs);
}
}
class Supervisor extends Employee {
public double GrossPay(double rate, double hrs) {
return ((rate*hrs)+3000.50);
}
}
class Manager extends Employee {
public double GrossPay(double rate, double hrs) {
return ((rate*hrs)+(5000.50));
}
}
Method Overloading
a
Method Clustering
b
Method Overriding
c
Method Calling
d
Question 49 (1 point)
class Shape {
private String shape = "Circle";
private static final double pie=3.14;
Is a method which cannot be inherited by its subclass without using an @Override tag.
a
Is a method in the child class that overrides a parent method.
b
Is any method in an abstract class.
c
A method from an abstract which needs a non-abstract class for it to be implemented.
d
Question 53 (1 point)
Can an abstract class define both abstract methods and non-abstract methods?
interface Shapes {
void DisplayShape();
void SetShape(String shape);
double AreaOfCircle(double r);
double AreaOfRectangle(double l, double w);
double AreaOfSquare (double s);
}
class Area implements Shapes {
interface Shapes {
public final double pie=3.14;
private String shape;
double AreaOfCircle(double r);
A class that implement interface must implement all the methods declared in the
a interface.
Interface classes could only define abstract methods and constants.
b
Nothing is wrong with the codes.
c
Interface classes should always define variables as private for data hiding.
d
Question 58 (1 point)
Shapes {
double AreaOfCircle(double r) {
return (pie * (r*r));
}
}
Blank 1:
Blank 2:
Question 59 (1 point)
void display() {
System.out.println("Employee Mgt.");
}
}
this.rate=rate;
this.hrs=hrs;
}
double GetSalary() {
return rate*hrs;
}
}
Nothing is wrong with the codes.
a
Abstract methods can only be declared within an abstract class.
b
abstract double GetSalary(); should be implement first in the parent class.
c
Abstract methods cannot be inherited by a subclass if the parent class is not declared
d abstract.
Question 60 (1 point)
Assuming item #39 has error/s, what should a programmer do to correct it?