Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Question Paper

1.Answer the following:

a) How many characters are there in ASCII and unicode?


b) What do you mean by the precision of a data type?
c) Differentiate between a pure and an impure mathematical expression?
d) Write the use of java.awt,java.math,java.text packages?
e) What is encapsulation?
f) What is a documentation comment?
g) Define switch statement?
h) Differentiate between a switch and a if else statement?
i) Write the syntax to accept an integer, a char and a string using stream class?
j) What is a runtime error? Explain with an example?

2. Answer the following:

a) Rewrite this using switch case:


if(var ==1)
System.out.println("Distinction");
else if(var == 2)
System.out.println("First division");
else if(var ==3)
System.out.println("Second division");
else if(var == 4)
System.out.println("Third division");
else
System.out.println("invalid choice");

b) Rewrite the following snippet using ternery operator:

if (bill>10000)

discount = bill * 10.0/100;

else

discount = bill * 5.0/100;

c) Give the output of the following program segment and also mention how many times the loop is
executed :

int i;

for (i = 5; i > 10; i++)


{

system. out. println (i);

system .out. println (i*4);

d) write a java program to find Cos 60 tan60 and Sin 60.

e) Convert the following loop in to do while and while loops:

for (int i = 1; i <= 10; ++i) {

System.out.println("Line " + i);

3. Write the following programs:

a. The relative velocity of two trains travelling in opposite direction is calculated by adding their
velocity. In case the trains are traveling in the same direction, the relative velocity is the
difference between their velocities.write a program to input velocities and length of the trains
and find the relative velocities and the time taken to cross each other.(using Switch case)
b. Write a java program using switch case and loop to find out the sum of the following series as
per users choice:
a) 1+1+2+3+5+...........upto n terms
b) 1+(1*2)+(1*2*3)+.............. +(1*2*3*.........*n)
c) 1+(1+2)+(1+2+3)+.............+(1+2+3+..........+n)

C.write java program to check if a number is a special two digit number and niven number or not.

d)

You might also like