A. Accessor and Mutator Methods
A. Accessor and Mutator Methods
In order for as to encapsulate and to restrict access directly to an instance variable, we use
__________ and ___________ to access, change or assign value of instance variable.
2. If you want your class, methods or fields accessible everywhere, you need to define what type of
access modifier?
A. Default
B. Protected
C. Public
D. Private
4. In java we cannot create instance of this reference type. This applies to?
A. Inheritance
B. Polymorphism
C. Encapsulation
D. Abstraction
E. Interface
A. Inheritance
B. Polymorphism
C. Encapsulation
D. Abstraction
E. Interface
6. This access modifier can only be used to a methods or fields and can only be used either on the same
package or in sub-classes?
A. Default
B. Protected
C. Public
D. Private
A. It is a method
B. It is a field
C. It is an object
D. It is a property
1. Private
2. Default
3. Protected
4. Public
12. In java we can define 2 or more constructors as long as they have different number and type of
parameters. This approach is what we called?
A. Method overriding
B. Method overloading
D. Inheritance
13. When using this modifier to a class, methods or fields this means that it can only be accessed with in
the class itself?
A. Default
B. Protected
C. Public
D. Private
14. What would be the result of the following code?
package StringMethods;
B. Compile error
C. Runtime Error
16. What would be the result of the following program, when you assign an integer 5 using the console?
public Test() {
int x = scan.nextInt();
A. x = 5
B. Compile error
C. Runtime Error
D. x = null
17. This concepts in Object Oriented Programming that allows an object to be created differently from
the same class.
A. Inheritance
B. Polymorphism
C. Encapsulation
D. Abstraction
18. This type of methods that do not have the body on it’s class.
A. static
B. private
C. protected
D. abstract
A. True
B. False
C. Only literals
D. Only object
20. In java, when you want to define the methods that is repeating and do same action to several
classes, it is suggested to use the ___________.
A. Inheritance
B. Polymorphism
D. Interface
21. This concepts in Object Oriented Programming that you can acquire the methods and fields of a
class.
A. Inheritance
B. Polymorphism
C. Encapsulation
D. Abstraction
24. This type of class which exist only for the purpose of Polymorphism and Inheritance.
A. static
B. private
C. protected
D. abstract
25. This is the OOP concept hides the implementation details from a user and highlighting only the
important part?
A. Inheritance
B. Polymorphism
C. Encapsulation
D. Abstraction
26. What type of access modifier when you supply no modifier at all to a class, methods or fields?
A. Default
B. Protected
C. Public
D. Private
28. In order for us to get value from a methods, we will use the keyword _______?
A. public
B. static
C. return
D. get
29. In java, when we a derived class has a definition for one of the member of the base class is what we
called?
A. Method overriding
B. Method overloading
D. Inheritance
A. True
B. False
31. Which of the following is not true about Interface?
B. An interface is written in a file with a .java extension, with the name of the interface matching the
name of the file
D. Interfaces appear in packages, and their corresponding bytecode file must be in a directory structure
that matches the package name.
32. If you want to implements the Interface from a class, you need to supply what java keyword to a
class definition?
A. extends
B. implements
C. acquire
D. override
33. This is the OOP concept that variables of a class will be hidden from other classes, and can be
accessed only through the methods of their current class.
A. Inheritance
B. Polymorphism
C. Encapsulation
D. Abstraction
A. true
B. False
C. Maybe
35 – 36.
Aw Aw
41. Hero
42. Player
45. extends
46. FireArms
47. Pistol
48. FireArms
49. class
50. Player
51- 108
package com.buksu.it.game;
delta.addPlayerToSquad(delta_one);
delta.addPlayerToSquad(delta_two);
delta.addPlayerToSquad(delta_three);
delta.addPlayerToSquad(delta_four);
delta.addPlayerToSquad(delta_five);
}
}
51 – 108:
package com.buksu.it.game;
public class Main {
public static void main(String[] args) {
Team delta = new Team("Delta Team");
Team omega = new Team("Omega Team");
delta.addPlayerToSquad(delta_one);
delta.addPlayerToSquad(delta_two);
delta.addPlayerToSquad(delta_three);
delta.addPlayerToSquad(delta_four);
delta.addPlayerToSquad(delta_five);
omega.addPlayerToSquad(omega_one);
omega.addPlayerToSquad(omega_two);
omega.addPlayerToSquad(omega_three);
omega.addPlayerToSquad(omega_four);
omega.addPlayerToSquad(omega_five);
delta_one.addItems(pistol);
delta_one.addItems(bag);
omega_one.addItems(shotgun);
omega_one.addItems(bag);
}
}