Displaying 5 out
of 25
questions & answers.
Q1.
Fill in the blanks.
- A program is a set of ______________ given to the computer to perform a task and give a ___________________.
- An ________________ translates and finds the error one line at a time.
- When an integer input is expected, but the user provides a name (string), this type of error is ______________________ error.
- The name of variables should be _____________________.
- Smallest value for an int data type is _______________ and the largest is _____________.
S A
M P L E
S
A M P L E
www.bigslate.com
Answer:
S A M P L E
answer not shownQ2.
State whether the following statements are True (T) or False (F).
- Character literals are enclosed within double quotes.
- The % operator gives the remainder.
- The name given to a memory location is called a variable.
- Double is a data type that stores only integers.
- In an 'if-else' block, the 'if' statment is optional.
S A
M P L E
S
A M P L E
www.bigslate.com
Answer:
S A M P L E
a. False
b. True
c. True
d. False
e. False
Q3.
Find the errors in the following statements and re-write it making necessary corrections.
- int a;b;c;
- int a, float b;
- int a=12.3;
- float a=12.69;
S A
M P L E
S
A M P L E
www.bigslate.com
Answer:
S A M P L E
- int a, b, c;
- int a;
float b; - float a=12.3f;
- float a=12, 69f;
Q4.
State whether the following variable names are valid/invalid. If invalid, rectify it.
- name1
- float
- c.p.
- A>B
S A
M P L E
S
A M P L E
www.bigslate.com
Answer:
S A M P L E
a. name1 - valid
b. float - invalid; corrected name - float1
c. c.p. - invalid; corrected name - cp
d. A>B - invalid; corrected name - AB
Q5.
Write statements in Java for the following:
- Declare a variable a and b of integer type.
- Declare an integer variable x and initialize it with 73.
- Assign the sum of the variable m and n into the variable q.
- Check whether the value in variable a is greater than or equal to the value in variable b.
- Divide x with y and store the remainder in x.
S A
M P L E
S
A M P L E
www.bigslate.com
Answer:
S A M P L E
int a, b;int x = 73;q = m + n;if (a >= b)
{
System.out.println (a + "is greater than or equal to value in b");
}int x, int y;x = (x % y);































































































