Homework 3
This commit is contained in:
parent
bf60a078d7
commit
0afc86ceeb
129 changed files with 3163 additions and 4316 deletions
|
@ -0,0 +1,7 @@
|
|||
// Error: the return type of the "main" method must be "void"
|
||||
|
||||
class Main {
|
||||
int main() {
|
||||
return 10;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
// Error: the main method must have no arguments
|
||||
|
||||
class Main {
|
||||
void main(Object[] args) {}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
// Error: there is no class called Main (case-sensitive)
|
||||
|
||||
class MAIN {}
|
||||
class main extends Object {}
|
|
@ -0,0 +1,11 @@
|
|||
// Error: the "Main" class does not contain a method called "main"
|
||||
|
||||
class Main {
|
||||
void maini() {}
|
||||
void mein() {}
|
||||
void moon() {}
|
||||
}
|
||||
|
||||
class NotMain extends Main {
|
||||
void main() {}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// The main method can be inherited from another class
|
||||
|
||||
class OtherMain {
|
||||
void main () {}
|
||||
}
|
||||
|
||||
class Main extends OtherMain {}
|
|
@ -0,0 +1,15 @@
|
|||
// The main method can be overridden in the inherit process, as any other method can
|
||||
|
||||
class A {
|
||||
void main() {
|
||||
write(1);
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
void main() {
|
||||
write(2);
|
||||
}
|
||||
}
|
||||
|
||||
class Main extends B {}
|
Loading…
Add table
Add a link
Reference in a new issue