CSG9fullportion qp23-24
CSG9fullportion qp23-24
Question 2: [20]
i. Find the output for the following: [2]
a. System.out.println("WELCOME"+20+20);
b. System.out.println(`e'+20+"20");
ii. Name the type of conversion in statement 1 and statement 2: [2]
char ch=’C’;
System.out.println((ch+1)); // statement 1
System.out.println((char)(ch+1)) ;// statement 2
iii. Name the following: [2]
a. The keyword which converts variable into constant.
b. The method which terminates the entire program from any stage.
iv. Rewrite the following program segment using logical operators: [2]
if ( x > 5 )
if ( x > y ))
System.out.println (x+y);
v. What will be the output when the following code segment is executed? [2]
char ch=’C’;
System.out.println((ch+ 1 )-+ " "+ ++ch);
vi. Write the difference between Math.ceil() and Math.floor(). [2]
vii. Convert the following for loop into do while loop: [2]
for (i = 10 ; ; i = i – 3)
{
if (i==4)
break;
System. out. print(i);
}
viii. Give the output of following code and mention how many times the loop will execute? [2]
int i=5;
while (i-- >=1)
{
if (i%2 ==1)
continue;
System.out.print(i+" ");
}
ix. Identify and name the following tokens: [2]
a. public b) 'a' c) = = d) { }
x. Answer the following as instructed: [2]
a. Write a Java expression for the following: |x2 + 2xy |
b. What will be the output:
System.out.println("\"I\" am the \n\Topper\””);
Question 3: [15]
Each Program should be written using variable description / mnemonic codes.
Define a class employee having the following description :
Data members/instance variables:
int pan — to store personal account number
String name — to store name
double tax income — to store annual taxable income
double tax — to store tax that is calculated
Member functions:
input() — Store the pan number, name, taxable income
calc() — Calculate tax for an employee
display() — Output details of an employee
Write a program to compute the tax according to the given conditions and display the output as per given format.
output:
Question 4: [15]
Write a menu driven java program to perform the following task according to user’s choice. Accept the values
as and when required:
a. Print the following series: 0,7,26, 63..... N terms.
b. Print the sum of the following series: 1/1-2/4+3/9-4/16....n terms
c. Print the sum of the following series: x2 + x4 + x6 + x8 …. n terms.
Question 5: [15]
Write a java program to check whether the entered number is a tech number or not.
A tech number has even number of digits. If the number is split in two equal halves, then the square of sum of
these halves is equal to the number itself. Write a program to generate and print all four digits tech numbers.
Example:
Consider the number 3025
Square of sum of the halves of 3025 = (30 + 25)2
= (55)2
= 3025 is a tech number.
Question 6: [15]
Write a program to computerize the billing operation of a telephone of a telephone company. The bill has to be
generated based on the following conditions:
A rent of Rs 120 is charged from every customer. A tax of 15% is charged on the sum of charges and rent. The
total amount is tax added to the sum of charges and rent .Print the bill for a customer.
Question 7: [15]
n
a. Write a program in java to print the Mersenne Numbers (i.e., the numbers in the form 2 − 1).
Read a limit from user and print all numbers until it exceeds the given limit. Also mention which(nth) number
has exceeded the limit.
b. Write a Java Program that reads a string and tests whether it begins with an uppercase letter or not
Question 8: [15]
Write a menu driven java program to perform the following task according to user’s choice.
1. Check whether a number is a palindrome number
A palindrome number is a number that is the same after the reverse.
2. Print Tribonacchi series:
0, 1, 1, 2, 4, 7, 13…n terms.