Homework 3
This commit is contained in:
parent
bf60a078d7
commit
0afc86ceeb
129 changed files with 3163 additions and 4316 deletions
|
@ -0,0 +1,8 @@
|
|||
// Multiple classes can't share the same name
|
||||
|
||||
class Aclass {}
|
||||
class Aclass {}
|
||||
|
||||
class Main {
|
||||
void main() {}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// Two fields in a class cannot share the same name
|
||||
|
||||
class Main {
|
||||
void main() {}
|
||||
int a;
|
||||
Object b;
|
||||
Main a;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// Two local variables in a method cannot share the same name
|
||||
|
||||
class Main {
|
||||
void main() {}
|
||||
void test() {
|
||||
int a, a;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// test double declaration
|
||||
// test local variable and parameter have same name
|
||||
|
||||
class Main {
|
||||
void main() {}
|
||||
int action(int p1, boolean p2) {
|
||||
Object p1;
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
// No pair of parameters in a method declaration can have the same name
|
||||
|
||||
class Main {
|
||||
void main() {}
|
||||
int action(int p1, boolean p2, Object p, Object p) {}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// No class can have the name "Object"
|
||||
|
||||
class Aclass {}
|
||||
class Object extends Aclass {}
|
||||
class Main extends Object {
|
||||
void main() {}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue