Find the error in the given code :
1 public class Example20{
2
public static void main(String[] args){
3
int a = 0;
4
int b=2;
5
int c = 3;
6
if(a++) {
7
b = a * c;
8
a /= 2;
9
}else {
10
b = b * b;
11
++c;
12}}}
Find the error in the given code :
1. Error at line number 2
2.Error at line number 6
3.Error at line number 7
4..Error at line number 10.
(2)
Due to the code at line number 6, this code will not compile. Since " if " statement takes 'Boolean' or 'conditional expression' as argument .
The output of the following program will be :
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from int to boolean
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.