what is Assertion?

Answer Posted / raja moram

The concept of suspending the execution of a function based
on the user defined condition is known as ASSERTION.
We implement the concept of Assertions using 'assert' keyword.
We use 'assert' keyword by mentioning a condition, if the
mentioned condition is not satisfied the 'assert' keyword
suspends the execution of the method in the middle and
transfers the control along with the 'AssertionError' class
object to the calling place.
Here 'AssertionError' is the subclass of 'Error'class.
To enable Assertions application:
java -ea <className>
This concept of ASSERTIONS is introduced from JDK 1.5 onwards

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how hashmap works?

598


Who found java?

557


What is a private class in java?

513


What are the methods used to implement for the key object in the hash map?

571


Can an interface have a constructor?

518






How is java created?

542


What is nan in java?

525


What are adapter classes?

608


Explain purpose of sleep() method in java?

626


What is a hashmap used for?

652


Can we override tostring method in java?

535


What is considered an anti pattern?

533


Name few java.lang classes introduced with java 8 ?

541


Explain the difference between an object-oriented programming language and object-based programming language?

551


Can sleep() method causes another thread to sleep?

571