Homework 4
This commit is contained in:
parent
0afc86ceeb
commit
72cc3206c4
125 changed files with 4200 additions and 1636 deletions
14
javali_tests/HW4_nop90/Assignments/OkArraySubtypes.javali
Normal file
14
javali_tests/HW4_nop90/Assignments/OkArraySubtypes.javali
Normal file
|
@ -0,0 +1,14 @@
|
|||
// any array is a subtype of Object
|
||||
// assignment and 'is equal' with an object of type 'Object' is fine
|
||||
|
||||
class Main {
|
||||
void main() {
|
||||
boolean y;
|
||||
Object x;
|
||||
int[] testArray;
|
||||
testArray = new int[10];
|
||||
x = testArray;
|
||||
testArray = null;
|
||||
x = null;
|
||||
}
|
||||
}
|
21
javali_tests/HW4_nop90/Assignments/OkSubtypes.javali
Normal file
21
javali_tests/HW4_nop90/Assignments/OkSubtypes.javali
Normal file
|
@ -0,0 +1,21 @@
|
|||
// assignment of subtypes
|
||||
|
||||
class Main {
|
||||
void main() {
|
||||
A a1, a2;
|
||||
B b1, b2;
|
||||
C c;
|
||||
a1 = new A();
|
||||
b2 = new B();
|
||||
c = new C();
|
||||
a2 = a1;
|
||||
b1 = c;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class A {}
|
||||
|
||||
class B extends A {}
|
||||
|
||||
class C extends B {}
|
Loading…
Add table
Add a link
Reference in a new issue