Question 03:
Which
of the following identifiers are valid? Which are Java keywords?
miles, Test, a++, ––a, 4#R, $4, #44, apps
class, public, int, x, y, radius
Ans:
The valid identifier are miles, Test, $4,
apps, x, y, radius.
Java keywords are int class public.
Question 04:
Identify and fix the errors
in the following code:
public class Test {
public static void main(String[] args) {
int i = k + 2;
System.out.println(i);
}
}
Ans:
A variable must be declared before it use variable k is not
declared
Error in int i=k+2; k is not declared.
Question 05:
What are the benefits of using constants? Declare an int constant SIZE with value 20.
Ans:
01 It is used for multiple times I the program
02
Its value can be changed at single location
03 It make easy to understand the
program
No comments:
Post a Comment