0% found this document useful (0 votes)
4 views26 pages

Java Class and Compilation Issues

Các cách triển khai hashcode thông dụng: 1. Trả về giá trị của 1 trường dữ liệu duy nhất trong đối tượng. Ví dụ trả về id. 2. Tính tổng các trường dữ liệu then chuyển sang int. 3. Sử dụng hàm hashcode của lớp Object. Cách 1 v

Uploaded by

Le Huy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views26 pages

Java Class and Compilation Issues

Các cách triển khai hashcode thông dụng: 1. Trả về giá trị của 1 trường dữ liệu duy nhất trong đối tượng. Ví dụ trả về id. 2. Tính tổng các trường dữ liệu then chuyển sang int. 3. Sử dụng hàm hashcode của lớp Object. Cách 1 v

Uploaded by

Le Huy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Title Lorem

Ipsum
SIT DOLOR AMET
Answer: 3,5
1.B( ) { }

2.B(int y ) { j = y; }

3.B(int y )
{ super(y*2 ); j = y; }

4.B(int y ) { i = y; j =
y*2; }

5.B(int z ) { this(z,
z); }
Answer: 3

1.0

2.1

3.2

4.-1

5.-2

6.3

7.X>a?(y>b?y:b) : (x>z?x:z)
Answer: 6
[Link] for interface House will cause
compilation to fail.

[Link] for interface Bungalow will cause


compilation to fail.

[Link] for class MyHouse will cause


compilation to fail.

[Link] at //1 will cause compilation to fail.

[Link] at //2 will cause compilation to fail.

[Link] code will compile successfully.


Answer: 1
[Link] bye friend!

[Link] good good

[Link]

[Link] bye

[Link] of the above.


You have written some Java code
in [Link] file. Which of the following
commands will you use to compile and run it.
(Assume that the code has no package declaration.)

[Link] [Link]
javar MyFirstClass

[Link] [Link]
javar [Link]

[Link] [Link]
java [Link]

[Link] [Link]
javar [Link]

[Link] [Link]
java MyFirstClass
Answer: 2,3,4
[Link]([Link]);

[Link]([Link]());

[Link](((Eagle)f).na
me);

[Link](((Bird)f).get
Name());

[Link]([Link]);

[Link]([Link]
(f));
Answer: 5
1.0 followed by 100.

2.100 followed by 100.

3.0 followed by 200.

4.100 followed by 200.

5.200 followed by 200.

6.200 followed by 100


Answer: 3
[Link], int

[Link], double

[Link], double

[Link], int

[Link], they are simply not


compatible.
Answer: 2
[Link] change is necessary.

[Link] [Link](k); with


[Link](k--);

[Link] [Link](k); with


[Link](--k);

[Link] while(checkIt(k)) with w


hile(checkIt(--k)).

[Link] return k-->0?


true:false; with return this.k-->0?
true:false;
Answer: 2
1.i=6 j=6

2.i=5 j=6

3.i=5 j=5

4.i=6 j=5

[Link] of these.
Answer: 1
[Link] will not compile.

[Link]

[Link]
false

[Link] at run time.


Answer:
1.2

2.3

3.4

4.5

5.6
Answer: 4
1.10 9

2.10 10

3.6 9

4.6 10

5.5 11
Answer: 1
[Link] Number

[Link] Object

[Link] Long

[Link] Integer

[Link] will not compile.


[Link] 44
4 44
Beta 44
44 44

[Link] 44
4 44
Baap 44
44 44

[Link] 44
4 44
Beta 44
44 44

4.4 44
Beta 44
44 44
Beta 44

5.44 44
Beta 44
4 44
Beta 44

6.4 44
Beta 44
4 44
Beta 44
1.array2 = array3;

2.array2 = array4;

3.array1 = array2;

4.array4 = array1;

5.array5 = array3;
[Link] will not compile.

[Link] will throw an exception at


runtime.

[Link] will print numbers from 0 to 8

[Link] will print numbers from 0 to 3

[Link] will print numbers from 0 to 4


[Link] base field

[Link] height field

[Link] area field

[Link] Triangle constructor

[Link] setBase method

[Link] setHeight method


Các method trên method nào là
override vs overload?
Thêm final, static vô line 2 được
ko?

Thêm final vs static vô line 3 hoặc


6 được ko?
Which of the following statements
are true?
Cách triển khai hashcode nào là
đúng ?

You might also like