-
Notifications
You must be signed in to change notification settings - Fork 0
/
answer.txt
executable file
·22 lines (18 loc) · 1.16 KB
/
answer.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
---------
| LAB02 |
---------
Q: If you create a constructor method to build a DVD by title then create a constructor method to build a DVD by category. Does JAVA allow you to do this?
---
A: Yes, it allows. Since JAVA has a feature called "Method Overloading", which means two or more methods may have the same name if they differ in parameters (different number of parameters, different types of parameters, or both).
---------
| LAB03 |
---------
Q1: Is JAVA a Pass by Value or a Pass by Reference programming language?
----
A1: Java is always Pass by Value and not pass by reference.
Q2: After the call of swap(jungleDVD, cinderellaDVD) why does the title of these two objects still remain?
----
A2: Because Java passes all arguments to a method in form of pass-by-value, when passing `jungleDVD` and `cinderellaDVD`, which are two references, only their method copied refs were passed, not the original refs. Therefore, original refs to objs remain unchanged.
Q3: After the call of changeTitle(jungleDVD, cinderellaDVD.getTitle()) why is the title of the JungleDVD changed?
---
A3: Because we called out the setter setTitle, it only changed the name of the JungleDVD.