without answers! Good luck!
- What is assert good for?
- When was Assertions added? Which Java version?
- There are 2 options to use the assert keyword, and they look like..?
- How do you enable Assertions?
- Assume Assertions is enabled, what happens when the following method is called where the passed argument is 1?
void foo(final int x) { assert x != 1; }
- So what is the protocol with the AssertionError? What do you do with it?
- How do you add additional information to an AssertionError?
- Assume you are working with the Java 1.7 compiler and you have a .java file where assert is used as an identifier instead of a keyword. (Which means the source code you have was written in Java 1.3 time..) Is it possible to compile this file? If yes, how and will you get any warnings?
- Which of the following are appropriate? True / False..
- It is fine to use the assert keyword to validate arguments passed to a public method.
- It is fine to use the assert keyword to validate arguments passed to a private method.
- It is fine to use the assert keyword to validate arguments passed to the main method.
- It is fine if assertions cause side effects.
- You can use the assert keyword to validate paths that should never be reached, even in public methods.
- No one cares if you catch the AssertionError, since it is a Throwable and you actually can catch it.