Computer Application Examination: (Email ID:)
Computer Application Examination: (Email ID:)
Question 2
(a) Differentiate between if else if and switch-case statements. [2]
(b) Write the prototype of a function check which takes an integer as an argument and returns a character.
[2]
(c) Name any two types of access specifiers. [2]
(d) What are the two ways of invoking functions? [2]
(e) Name any two types of constructors. [2]
Question 3
(a) Write a Java expression for the following: | 𝑥 2 + 2𝑥𝑦 | [2]
(b) Write the output for the following: [2]
System.out.println(“Incredible”+”\n”+”World”);
(c) Why is an object called an instance of a class? [2]
(d) What is the value of x1 if x = 5? x1 = ++x – x++ + --x [2]
(e) State the difference between == operator and equals() method. [2]
Question 4
(a) Rewrite the following using ternary operator: [2]
if(x%2 == 0)
System.out.println(“EVEN”);
else
System.out.println(“ODD”);
(b) State the package that contains the class: [2]
i) BufferedReader
Page 1 of 3
ii) Scanner
(c) Give the output of the following: [2]
Math.sqrt(Math.max(9,16));
(d) Give the output of the following string functions: [2]
i) “ACHIEVEMENT”.replace(‘E’,’A’);
ii) “DEDICATE”.compareTo(“DEVOTE”);
(e) If int y = 10 then find: int z = (++y*(y++ + 5)); [2]
Question 5
Define a class named ShowRoom with the following description: [15]
Instance variables/data members:
String name : stores the name of the customer
long mobno : stores the mobile number of the customer
double cost : stores the cost of the items purchased
double dis : stores the discount amount
double amount : stores the amount to be paid after discount
Member Methods:
ShowRoom() : default constructor to initialize data members
void input() : to input customer name, mobile number, cost
void calculate() : to calculate discount on the cost of purchased items, based on following criteria
void display() : to display the customer name, mobile number, amount to be paid after discount
Write a main method to create an object of the class and call the above member methods.
Question 6
Write a program to input twenty names in an array. Arrange these names in descending order of alphabets using
the bubble sort technique. [15]
Question 7
Design a class to overload a function volume() as follows: [15]
Question 8
Using switch statement, write a menu driven program for the following: [15]
i) to find and display the sum of the series given below:
𝑆 = 𝑥1 − 𝑥 2 + 𝑥 3 − 𝑥 4 + 𝑥 5 … … … … … − 𝑥 20
ii) to display the following series:
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.
Question 9
Write a program to input and store roll numbers, names and marks in 3 subjects of n number students in five
single dimensional array and display the remark based on average marks as given below. (the maximum marks
in the subject are 100). [15]
𝑇𝑜𝑡𝑎𝑙 𝑚𝑎𝑟𝑘𝑠
𝐴𝑣𝑒𝑟𝑎𝑔𝑒 𝑚𝑎𝑟𝑘𝑠 =
3
Question 10
Using the switch statement, write a menu driven program to: [15]
i) To find and display all the factors of a number input by the user (including 1 and excluding the
number itself).
Example:
Sample Input: n = 15
Sample Output: 1, 3, 5
ii) To find and display the factorial of a number input by the user (the factorial of a non-negative
integer n, denoted by n!, is the product of all integers less than or equal to n.
Example:
Sample Input: n=5
Sample Output: 5! = 1*2*3*4*5 = 120
Page 3 of 3