TEST
A) Find the output of the following\ Write the Print Statment for the output :
i) int a = 5;
a+=(int)Math.random()*6>((int)Math.max(Math.ceil(-3.4),Math.floor(-0.6)))?'A':55;
System.out.println(a); [3]
ii) System.out.println(Math.pow(16,1/2)-Math.pow(16,1/2.0)*Math.sqrt(-(-1))); [3]
iii) int a = 65;
char ch = (char) a;
System.out.println(++ch +'A' + "Hello World"); [3]
iv) Write the print statment for the output : He told , "I was born on 10\10\2007"
( for this type of question , get the reference from the example below : -
eg - Q) Write the print statment for the output : Hello , he's 5 years old
Ans) System.out.println("Hello ,he\'s 5 years old")
) [3]
B) Write java program for the given question :
1) Write a program to find the ASCII value of the character ' * ' using explicit convertion [4]
2) Write a program to 2 numbers and find the sum of thier squares [4]
3) Write a program to enter a number and check it is a perfect square or not. A number is said to
be a perfect square when its root has no decimal part it in for example : square root of 16 is 4 so it is a
perfect square. [6]
4) Write a program to enter a decimal number and round it off to its nearest 2 decimal point and display
it. For example , if the input is 1234.57 then the output should be 1234.6 [6]
5) Write a menu driven program to input the height (h) , radius (r) of a cylinder and display the its Curve
Surface area (CSA) or Total Surface Area (TSA) or its volume according to the choice of the user.[6]
take Pie(π) = 22/7
CSA = 2 x Pie x r x h
TSA = 2 x Pie x r x ( r+h)
Volume = Pie x r x r x h
6) Write the java expression using Math Functions for the following : [6]
i)
ii)
iii)
for example :
output will be -->( Math.pow(a,2) + Math.pow(b,2) )/2*a*b
7) Prtyush is new to Java programming so he write the code in jave given below :
Analyse the code , and Write down what possible errors he might get why compliling or running this code
from line 4 - 12 [6]