1. What is the output of the following lines of code?
int a = 6;
int b = 7;
int c = 3;
System.out.println("1. " + (a+b));
System.out.println("2. " + (b-c));
System.out.println("3. " + (b%a));
System.out.println("4. " + (b%c));
System.out.println("5. " + (b%b));
b++;
System.out.println("6. " + b);
a--;
System.out.println("7. " + a);
2. Assume that the following operations have occurred:
int a = 4;
int b = 6;
float c = 6.42;
char d = ‘A’;
Output the following using variables whenever possible.
(a) Radius = 4
(b) Area = 6
(c) Area = 6.42
(d) ***A***
(e) --- 6 --- 4 ---
(f) @->->-
(g) 4 6
(h) 6.4
(i) 6.42 A A
(j)
**
* *
**
3. Fill in the blanks:
public _____a____ _____b____
{
___c_____ static void main (____d____ args [])
{
new MathTest ();
}
public ____e_____ ()
{
int a = 6;
int b = 7;
____f__ c = a + b;
____g__.out.println (a + " + " + b + " = " + c);
}
}
4. Find 5 errors in the following code:
public Hello
{
public static main (String args [])
{
new Hi ();
}
public Hello ()
{
System.out.printsln ("Hello")
}
}