0% found this document useful (0 votes)
33 views3 pages

Comp 9

This document contains a 70 mark computer exam paper with multiple choice, numerical and programming questions. The paper tests concepts in Java including variables, data types, operators, loops, conditional statements, functions and classes. It has two sections with the second section containing longer programming questions on calculating library fines, volume of solids and checking if a two-digit number is special.

Uploaded by

Soumya Bishnu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views3 pages

Comp 9

This document contains a 70 mark computer exam paper with multiple choice, numerical and programming questions. The paper tests concepts in Java including variables, data types, operators, loops, conditional statements, functions and classes. It has two sections with the second section containing longer programming questions on calculating library fines, volume of solids and checking if a two-digit number is special.

Uploaded by

Soumya Bishnu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

FM: 70 COMPUTER TIME: 90 mins

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]

Q5 Give the output of the following: [2]


(i) Math.floor(-4.7)
(ii) Math.ceil(3.4) + Math.pow(2, 3)
Q6 Convert the following if else if construct into switch case: [4]
if(var == 1)
System.out.println("good");
else if(var == 2)
System.out.println("better");
else if(var == 3)
System.out.println("best");
else
System.out.println("invalid");
Q7 (i) State the number of bytes occupied by char and int data types? [2+2]
(ii) Write one difference between / and % operator.
Q8 a. Give the output of the following program segment and also mention the number of times the
loop is executed: [2]
int a,b;
for(a=6,b=4;a<=24;a=a+6)
{
if(a%b==0)
break;
}
System.out.println(a);
b. What is the value of y after evaluating the expression given below? y += ++y + y– + –y; when
int y = 8. [2]
Q9. class checkPrime { [3]
public static void main(String args[]) {
int i, f=0;
int n = Integer.parseInt(args[0]);
for(i=__1__; __2__; i++)
{
if(__3__==0)
{
f=__4__;
break;
}
}
if(f==__5__)
System.out.print(“The given no. “+n+” is a prime number”);
else
System.out.print(“The given no. “+n+” is not a prime number”);
}
}

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);
}

Q11 What is the output of the following? [2]


char c = ‘A’;
short m = 26;
int n = c + m;
System.out.println(n);
Q12 Analyse the given program segment and answer the following questions: [2+2]
for(i = 3; i <=4; i++)
{
for(j=2; j<i; j++)
{
System.out.print(""),
}
System. out.println("WIN");
}
How many times does the inner loop will execute?
Write the output of the program segment.
Q13 Give the output of the following program. [2]
int i,j;
for (i=0; i<4; i++)
{
for (j=i; j>=0; j--)
System.out.print(j);
System.out.println();
}
Q14 What will be the output of the following code? [2]
int m=2
int n=15;
for(int i=1;i<5;i++)
m++; - - n;
System.out.println("m="+m);
System.out.println("n="+n);
PART-2
Q15. A library charges fine for books returned late. [10]
Following are the fines:
first five days 40 paisa per day
Six to ten days 65 paisa per day
above 10 days 80 paisa per day.
Design a program to calculate the fine assuming that a book is returned N days late.
Q16. The volume of solids, viz. cuboid, cylinder and cone can be calculated by the Formula:
Volume of a cuboid: (v = l × b × h)
Volume of a cylinder: (v = π× r²× h)
Volume of a cone: (v = 1/3× π × r²× h) (π = 22/7)
Using a switch case statement, write a program to find the volume of different solids by taking
suitable variables and data types. [10]

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”.

You might also like