Discussion
The program is run with java -ea:com.acme.io... com.acme.util.Example31 - what will be the output?
package com.acme.util;
public class Example31
{
public static void main(String[] args)
{
int total = 0;
assert total > 0 : "total was " + total;
System.out.println("total " + total);
}
}
Answer: C
Assertions are enabled only for com.acme.io and its subpackages. The class is in com.acme.util, a sibling of that package rather than a subpackage of it, so it keeps assertions disabled and the false assertion is skipped. Sharing the prefix com.acme is not enough.
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