Previous Questions and Answers: 2018
COMPUTER APPLICATIONS
SECTION A (40 Marks)
Attempt all questions
Question 1
(a) Define abstraction. [2]
Abstraction refers to the act of representing essential features without including the background details or explanations in a class.
E.g.: A student object has so many attributes like roll, name, marks, caste, address etc. To find result all these attributes are not required. The essential features are roll, name and marks. All other background details is avoided.
(b) Differentiate between the searching and sorting. [2]
Searching: Finding an element in an arrray is known as searching. If an element is found the result is displayed with its position etc. If it is not found “Element is not found message is displayed”.
Sorting: Arranging element in ascending or descending order is known as sorting. If the elements are string the sorting is in alphabetical order.
(c) Write a difference between the functions isUpperCase() and toUpperCase(). [2]
isUpperCase(): It is Character class function that checks whether a character is upper case or not. It returns boolean value true or false. E.g.: Character.isUpperCase(‘N’) returns true.
toUpperCase(): It is Character class function that converts a character into upper. It returns character value. E.g.: Character.toUpperCase(‘a’) returns A.
(d) How are private members of a class different from public members? [2]
Private members of a class can be accessed by the members of the same class only. E.g.: private int a; This varibale can be accessed by a method of the same class only.
Public members of a class can be accessed by the members of all class in any package. E.g.: public int a; This varibale can be accessed by any method of any class in any package.
Primitive data types
(i) char (iii) int
Non-primitive data types
(ii) arrays (iv) classses
Question 2.
65
(ii) Name the package that contains wrapper classes. [2]
java.lang
(b) State the difference between while and do while loops. [2]
The while is an entry controlled loop that means the condition is checks before entering to the loop body. If the condition is true only the loop body executes other wise loop terminates.
The do while is an exit controlled loop that means the condition is checks only before exiting the loop body. If the condition is true then the loop body executes other wise loop terminates. The loop body executes atleast once.
BEST OF LUCK
(d) Write the prototype of a function check which takes an integer argument and returns a character. [2]
public static char check(int x)
(i) boolean
(ii) double
Question 3.
Math.sqrt(3*x+Math.pow(x,2))/(a+b)
33
(i) -5.0
(ii) 12.0
(d) Write two characteristics of a constructor. [2]
(i) A constructor is member function with its class name and it is used to create objects by initialising proper values to data memebrs.
(ii) A constructor has no return type and it is invoked at the time of object creation.
Incredible
India
(i) ACHIAVEMANT
(ii) -18
false
JAI
discount=(bill>10000)? bill*10.0/100 : bill*5.0/100;
20
Loop body does not execute.
SECTION B (60 Marks)
Attempt any four questions
Question 4
Design a class RailwayTicket with following description:
Instance variables/data members:
String name : To store the name of the customer
String coach : To store the type of coach customer wants to travel
long mobno : To store customer’s mobile number
int amt : To store basic amount of ticket
int totalamt : To store the amount to be paid after updating the original amount
Member methods:
void accept() - To take input for name, coach, mobile number and amount.
void update() - To update the amount as per the coach selected
(Extra amount to be added in the amount as follows)
Types of Coach - Amount
First_AC - 700
Second_AC - 500
Third_AC - 250
Sleeper - None
void display() - To display all details of a customer such as name, coach, total amount and mobile number
Write a main method to create an object of the class and call the above member methods. [15]
Question 5
Write a program to input a number and check and print whether it is a Pronic number or not. (Pronic number is the number which is
the product of two consecutive integers)
Examples:
12=3x4
20=4x5
42=6x7
Question 6
Write a program in Java to accept a string in lower case and change the first letter of every word to upper case. Display the new string.
Sample input: we are in cyber world.
Sample output: We Are In Cyber World [15]
Question 7
Design a class to overload a function volume() as follows:
(i) double volume(double R) – with radius(R) as an argument, returns the volume of sphere using the formula: V=4/3 x 22/7 x R3
(ii) double volume(double H, double R) – with height(H) and radius(R) as the arguments, returns the volume of a cylinder using the formula: V=22/7 x R2 x H
(iii) double volume(double L, double B, double H) – with length(L), breadth(B) and height(H) as the arguments, returns the volume of a cuboid using the formula: V=L x B x H [15]
Question 8
Write a menu driven program to display the pattern as per user’s choice.
Pattern 1 Pattern 2
ABCDE B
ABCD LL
ABC UUU
AB EEEE
A
For an incorrect option, an appropriate error message should be displayed. [15]
Question 9
Write a program to accept name and total marks of N number of students in two single subscript array name[] and totalmarks[].
Calculate and print:
(i) The average of the total marks obtained by N number of students.
[average = (sum of total marks of all the students)/N]
(ii) Deviation of each student’s total marks with the average.
[deviation= total marks of a student – average] [15]