Given below the sample code :
Float pi = new Float(3.14f);
if (pi > 3) {
System.out.print("value of pi is greater than 3");
}
else {
System.out.print("value of pi is less than 3 ");
}
finally {
System.out.println("Now you know pi's value");
}
What will be the output of the following code ?
1. Error in compilation
2. value of pi is greater than 3 Now you know pi's value
3. value of pi is less than 3 Now you know pi's value.
4. Now you know pi's value
(1)
Error in compilation is due to the "finally" clause without "try".
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.