Java Day 3
- Choose the correct output among the following options.
- 13
- Compilation fails due to multiple errors.
- Compilation fails due to an error on line 7.
- Compilation fails due to an error on line 4.
- Compilation fails due to an error on line 9.
- Can a static variable be transient?
- Choose the correct output among the following options (Choose all that apply).
- Compilation succeeds
- Compilation fails due to an error on line 3.
- Compilation fails due to errors on line 4.
- Compilation fails due to an error on line 5.
- Compilation fails due to an error on line 6.
- Compilation fails due to an error on line 7.
class Frode extends Hobbit {
public static void main(String[] args) {
Short myGold = 7;
System.out.println(countGold(myGold, 6));
}
}
class Hobbit {
int countGold(int x, int y) {
return x + y;
}
}
class ShellClass {
public static void main(String[] args) {
for(int __x = 0; __x < 3; __x++);
int #lb = 7;
long []x[5];
Boolean []ba[];
enum Traffic{RED, YELLOW, GREEN};
}
}
Enum
- An enum class is a class declared with abbreviation syntax that defines a small set of named class instances.
- Enum actually internally converted to a java final class.
class ShellClass {
public static void main(String[] args) {
int enum = 10;
}
}
enum Color {
RED, GREEN, BLACK;
}
enum Color {
RED, GREEN, BLUE
}
class ShellClass {
public static void main(String[] args) {
Color BLACK = new Color();
}
}
Note: Shell Class is a class that contains the main() method.
Comments
Post a Comment