Discussion
The program is run with java -ea -da Sample37 - what will be the output?
public class Sample37
{
public static void main(String[] args)
{
double rate = 0.0;
assert rate > 0.0 : "rate not set";
System.out.println("rate " + rate);
}
}
Answer: A
Neither switch carries an argument, so both apply to the same set of classes and the later one settles it: assertions end up disabled, the check is skipped and the program prints rate 0.0. Ordering only decides the outcome when two switches have the same specificity; a more specific switch beats a general one wherever it appears.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development