Bai Tap Trac Nghiem Oop
Bai Tap Trac Nghiem Oop
Lập trình hướng đối tượng (Đại học Tôn Đức Thắng)
A.By adding argument "int size" to the method book at line number 3.
B.By removing argument '2' at line number 18.
C.By creating object of "SuperHotel" subclass at line 17 & calling book(2) from it at line 18
D.No correction needed.
Câu 11 At run-time, a Java program is nothing more than objects ‘talking’ to
___________.
A.Other objects
B.Other methods
C.Other classes
D.Other binders
Câu 12 If you don't have the access to the source code for a class, but you want to change
the way a method of that class works, then could you use subclassing to do that that is to
extend the "bad" class and override the method with your own better code?
A.True
B.False
Câu 13 The relation between the Car and Owner or BankAccount and Customer is an
example of
A.Aggregation
B.Composition
C.Association
D.None
Câu 14 Subclassing polymorphism is sometimes called “true polymorphism”.
A.True
B.False
Câu 15 Consider the below code and choose the correct output. public class Main { public
int a; public long b; public void test(long b) { System.out.println("long b"); } public void
test(int a) { System.out.println("int a"); } public static void main(String[] args) {
Main e=new Main(); e.test(9*1000000000); } }
A.Int a
B.Long b
C.Long a
D.Error
Câu 16 Polymorphism is one interface with __________.
A.Multiple methods
B.Single method
C.Multiple record
D.Single record
Câu 17 Interfaces are fast as they require extra indirection to find the corresponding
method in the actual class.
A.True
B.False.
Câu 18 Consider the code below and choose the correct option. class GameShape { public
void displayShape() { System.out.println("displaying shape"); } // more code } class
PlayerPiece extends GameShape { public void movePiece() { System.out.println("moving
game piece"); } // more code } public class TestShapes { public static void main
(String[] args) { PlayerPiece shape = new PlayerPiece(); shape.displayShape();
shape.movePiece(); } }