Predict the output for the following:
char c1=’a’, c2=’A’
int c=a+b;
System.out.println((char)(a-50));
Answers
Answered by
0
We will get an error when we run the given program.
Explanation:
Program:
public class Main
{
public static void main(String[] args)
{
char c1='a', c2='A';
int c=a+b;
System.out.println((char)(a-50));
}
}
Output:
Main.java:6: error: cannot find symbol
int c=a+b;
^
symbol: variable a
location: class Main
Main.java:6: error: cannot find symbol
int c=a+b;
^
symbol: variable b
location: class Main
Main.java:7: error: cannot find symbol
System.out.println((char)(a-50));
^
symbol: variable a
location: class Main
3 errors
We get an error because, we did not declared a and b variables.
Refer the attached image for the output.
Attachments:
Similar questions
Physics,
2 months ago
English,
2 months ago
Math,
6 months ago
History,
10 months ago
Social Sciences,
10 months ago