Professional Documents
Culture Documents
Question 1. [20]
(i) What is the return type of a method that does not return any value?
a) int b) float c) void d) double
(ii) In object-oriented programming, the stress is given on
a) procedure b) method c) class d) data
(iii) Which of the following principle does not allow to access directly from outside the class
premises?
(iv) Which type of loop is guaranteed to have the body execute at least once?
a). do-while b). while c). for d). for-each
(v) What keyword is used to end the current loop iteration and proceed execution with the next
iteration of that loop?
a). break b). continue c). end d). skip
int i = 0;
for(i = 0 ; i < 5; i++){
}
System.out.println(i);
(vii). Assertion (A): Java is platform-independent due to its "Write Once, Run Anywhere" (WORA)
capability.
Reason (R): Java code is compiled into bytecode, which can run on any platform with a
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of
Assertion(A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
(viii). Which of the following statements is true regarding encapsulation?
(ix). Assertive (A): Increment and decrement operators are binary operators
Reason (R): Increment and decrement operators require only one operand
(a) Both Assertion (A) and Reason (R) are true and Reason(R) is correct explanation of
Assertion (A).
(b) Both Assertion (A) and Reason (R) are true and Reason(R) is not correct.
(c) Assertion (A) is true and Reason (R) is false.
(d) Assertion (A) is false and Reason (R) is true.
a). 0 b). Run time Error c). Infinity d). Run time exception
(xi). Evaluate the following Java expression, if x=3, y=5, and z=10: ++z + y - y + z + x++
(xiii). Which of these access specifiers must be used for main() method?
1. class increment {
2. public static void main(String args[])
3. {
4. int g = 3;
5. System.out.print(++g * 8);
6. }
7. }
a) 32
b) 33
c) 24
d) 25
(a) Break
(b) Continue
(c) for()
(d) if()
(xviii). What will be the output of the following Java code?
1. class Output
2. {
3. public static void main(String args[])
4. {
5. double x = 3.14;
6. int y = (int) Math.ceil(x);
7. System.out.print(y);
8. }
9. }
a) 3
b) 0
c) 4
d) 3.0
1. class jump_statments
2. {
3. public static void main(String args[])
4. {
5. int x = 2;
6. int y = 0;
7. for ( ; y < 10; ++y)
8. {
9. if (y % x == 0)
10. continue;
11. else if (y == 8)
12. break;
13. else
14. System.out.print(y + " ");
15. }
16. }
17. }
a) 1 3 5 7
b) 2 4 6 8
c) 1 3 5 7 9
d) 1 2 3 4 5 6 7 8 9
Question 2.
(i) Define abstraction. [2]
√ a2 +b2
ab
(iv) State the difference between while and do while loop. [2]
(v) System.out.print("BEST "); [2]
System.out.println("OF LUCK");
(vi) What is the value of y after evaluating the expression given below? [2]
b. int x =12;
long y = x;
Question 3. [15]
Using the switch statement write a menu driven program for the following:
(i)
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Question 4. [15]
A certain amount of money is invested for 3 years at the rate of 6%, 8% and 10% per annum
compounded annually. Write a program to calculate:
Question 5. [15]
Write a program in Java to enter a number and check whether the number is an Armstrong number or not.
(A number is said to be Armstrong if the sum of the cubes of its digits is equal to the original number.)
Question 6. [15]
Using a switch case statement, write a menu driven program to convert a given temperature from
Fahrenheit to Celsius and vice-versa. For an incorrect choice, an appropriate message should be
displayed.
Hint: c = 5/9*(f-32) and f=1.8*c+32.
Question 7. [15]
Write a program to display all the 'Buzz Numbers' between p and q (where p<q). A 'Buzz Number' is the
number which ends with 7 or is divisible by 7.
Question 8. [15]
Write a class with the name Area using function overloading that computes the area of a square, a rectangle
and a circle.
Formula:
Area of a square = s * s