Comp 9
Comp 9
PART-1
Q1 (i)int var = ‘A’;
What is the value of var? [1]
(ii) Name the package that contains wrapper classes. [1]
Q2 Identify whether they are primitive or non-primitive types
(i) String (ii) arrays (iii) char (iv) classes [4]
Q3 System.out.print(“BEST “);
System.out.println(“OF LUCK”);
Choose the correct option for the output of the above statements: [2]
(i) BEST OF LUCK
(ii) BEST
OF LUCK
Q4 Write a Java expression for the following: [2]
Q10. Give the output and show the dry run. [3]
public static void abc()
{
int x=1, i=2;
do
{
x*=i;
}while(++i<=5);
System.out.println(x);
}
Q17. A special two-digit number is such that when the sum of its digits is added to the product
of its digits, the result is equal to the original two-digit number. [10]
Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of digits = 5 * 9 = 45
Sum of the sum of digits and product of digits = 14 + 45 = 59
Write a program to accept a two-digit number. Add the sum of its digits to the product of its
digits. If the value is equal to the number input, then display the message “Special 2 – digit
number” otherwise, display the message “Not a special two-digit number”.