Java Chapter 8- Test Questions and Answers|
Latest Update
_______ binding refers to the method definition being associated with the method invocation
when the code is compiled.
Answers:
Dynamic
Late
Early
None of these. ✔️✔️Early
________ refers to the ability to associate many meanings to one method name by means of
the late binding mechanism.
Answers:
Inheritance
Encapsulation
Polymorphism
None of these. ✔️✔️Polymorphism
________ refers to the process of associating a method definition with a method invocation.
Answers:
Binding
Encapsulation
Inheritance
, Polymorphism ✔️✔️Binding
Given:
1 class Dog {
2 public void bark() { System.out.print("woof "); }
3}
4
5 class Hound extends Dog {
6 public void bark() { System.out.print("howl "); }
7 public void sniff() { System.out.print("sniff "); }
8}
9
10 public class DogShow {
11 public static void main(String[] args) {
12 new DogShow().go();
13 }
14 void go() {
15 new Hound(). bark();
16 ((Dog) new Hound()).bark();
17 ((Dog) new Hound()).sniff();
18 }
19 }
-
Answers:
Latest Update
_______ binding refers to the method definition being associated with the method invocation
when the code is compiled.
Answers:
Dynamic
Late
Early
None of these. ✔️✔️Early
________ refers to the ability to associate many meanings to one method name by means of
the late binding mechanism.
Answers:
Inheritance
Encapsulation
Polymorphism
None of these. ✔️✔️Polymorphism
________ refers to the process of associating a method definition with a method invocation.
Answers:
Binding
Encapsulation
Inheritance
, Polymorphism ✔️✔️Binding
Given:
1 class Dog {
2 public void bark() { System.out.print("woof "); }
3}
4
5 class Hound extends Dog {
6 public void bark() { System.out.print("howl "); }
7 public void sniff() { System.out.print("sniff "); }
8}
9
10 public class DogShow {
11 public static void main(String[] args) {
12 new DogShow().go();
13 }
14 void go() {
15 new Hound(). bark();
16 ((Dog) new Hound()).bark();
17 ((Dog) new Hound()).sniff();
18 }
19 }
-
Answers: