Class Test
Class Test
The value of c is 20
Terminal
Answer 3.
False
PUR
Answer 5.
a.The value of p is 5.
b. 7+10*3=37
1. Integer- sc.nextInt();
2. Double- sc.nextDouble();
3. String- sc.next(); or sc.nextLine();
Answer 7.
System.out.print System.out.println
1. The cursor remains on the same line of the 1. The cursor moves to the next line of the
screen after producing the result. screen after producing the result.
2. The result is printed on the same line. 2. The result is printed on multiple lines.
Syntax: Syntax:
System.out.print(“HELLO”); System.out.println(“HELLO”);
System.out.print(“COMPUTER”); System.out.println(“COMPUTER”);
Output: Output:
HELLO COMPUTER HELLO
COMPUTER
Answer 8.
Syntax: Syntax:
if(condition) switch(variable)
{ {
expression 1; case 1:
} {
else expression;
{ break;
expression 2; }
} case 2:
{
expression;
break;
}
case 3:
{
expression;
break;
}
}
Answer 9:
//store 5 names
import java.util.Scanner;
class name
int i;
for(i=0;i<5;i++)
s[i]=sc.next();
for(i=0;i<5;i++)
System.out.println(s[i]);