Java Day 4
- What is the output of the following code?
class ShellClass {
public static void main(String[] args) {
int x = 10;
;;;;;
;;;;;
assert (x > 10);
}
}
Assert
Assertions are typically enabled when an application is being tested and deployed, but disabled when application
is deployed.
-ea is used to enable assertion and -da is used to disable assertion.
class ShellClass {
public static void main(String[] args) {
int assert;
}
}
class ShellClass {
public static void main(String[] args) {
assert "Hi";
}
}
class ShellClass {
public static void main(String[] args) {
int x = 10;
assert x > 10;
}
}
class ShellClass {
public static void main(String[] args) {
int x = 10;
assert x > 5 : "x is not greater than 5.";
assert (x > 15) : "x is not greater than 15.";
assert (x > 8) : "x is not greater than 8.";
}
}
Comments
Post a Comment