0% found this document useful (0 votes)
39 views25 pages

Computer PYQ 2015 2023

The document is an examination paper for Computer Applications, consisting of multiple questions covering various programming concepts, including Java syntax, data types, control structures, and class design. It is divided into two sections, with Section A requiring answers to all questions and Section B allowing for the selection of four questions. The paper includes theoretical questions, coding problems, and practical tasks related to Java programming.

Uploaded by

shahjansidd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views25 pages

Computer PYQ 2015 2023

The document is an examination paper for Computer Applications, consisting of multiple questions covering various programming concepts, including Java syntax, data types, control structures, and class design. It is divided into two sections, with Section A requiring answers to all questions and Section B allowing for the selection of four questions. The paper includes theoretical questions, coding problems, and practical tasks related to Java programming.

Uploaded by

shahjansidd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

COMPUTER APPLICATIONS Question 2.

(a) Name the following: [2]


(Theory)
(i) A keyword used to call a package in the program.
(Two Hours)
(ii) Any one reference data type.
Answers to this Paper must be written on the paper provided separately.
(b) What are the two ways of invoking functions? [2]
You will not be allowed to write during the first 15 minutes.
(c) State the data type and value of res after the following is executed: [2]
This time is to be spent in reading the question paper.
char ch='t';
The time given at the head of this Paper is the time allowed for writing the answers.
res= Character.toUpperCase(ch);
This Paper is divided into two Sections.
(d) Give the output of the following program segment and also mention the number [2]
Attempt all questions from Section A and any four questions from Section B.
of times the loop is executed:
The intended marks for questions or parts of questions are given in brackets[]. int a,b;
for (a = 6, b = 4; a <= 24; a = a + 6)
SECTION A (40 Marks)
{
Attempt all questions
if (a%b ==0)
Question 1. break;
(a) What is inheritance? [2] }
(b) Name the operators listed below: [2] System.out.println(a);

(i) < (e) Write the output: [2]


char ch = 'F';
(ii) ++
int m = ch;
(iii) &&
m=m+5;
(iv) ? :
System.out.println(m + " " + ch);
(c) State the number of bytes occupied by char and int data types. [2]

(d) Write one difference between / and % operator. [2] Question 3.


(a) Write a Java expression for the following: [2]
(e) String x[] = {"SAMSUNG", "NOKIA", "SONY", "MICROMAX", [2]
"BLACKBERRY"}; ax5 + bx3+c

Give the output of the following statements: (b) What is the value of x1 if x=5? [2]
(i) System.out.println(x[1]);
x1= ++x – x++ + --x
(ii) System.out.println(x[3].length ( ));
(c) Why is an object called an instance of a class ? [2]
This Paper consists of 5 printed pages and 1 blank page.
T17 861 Turn Over
© Copyright Reserved T17 861 2
(d) Convert following do-while loop into for loop. [2] SECTION B (60 Marks)
int i = 1; Attempt any four questions from this Section.
int d=5; The answers in this Section should consist of the Programs in either Blue J environment or any
do { program environment with Java as the base.
d=d*2; Each program should be written using Variable descriptions/Mnemonic Codes so that the logic
System.out.println(d); of the program is clearly depicted.
i++ ; } while ( i<=5); Flow-Charts and Algorithms are not required.
(e) Differentiate between constructor and function. [2] Question 4.
(f) Write the output for the following: [2] Define a class ElectricBill with the following specifications: [15]
String s="Today is Test" ; class : ElectricBill
System.out.println(s.indexOf('T')); Instance variables / data member:
System.out.println(s.substring(0,7) + " " +"Holiday"); String n – to store the name of the customer

(g) What are the values stored in variables r1 and r2: [2] int units – to store the number of units consumed

(i) double r1 = Math.abs(Math.min(-2.83, -5.83)); double bill – to store the amount to be paid

(ii) double r2 = Math.sqrt(Math.floor(16.3)); Member methods:


void accept( ) – to accept the name of the customer and number of units consumed
(h) Give the output of the following code: [2]
void calculate( ) – to calculate the bill as per the following tariff:
String A ="26", B="100";
Number of units Rate per unit
String D=A+B+"200";
First 100 units Rs.2.00
int x= Integer.parseInt(A);
Next 200 units Rs.3.00
int y = Integer.parseInt(B);
Above 300 units Rs.5.00
int d = x+y;
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
System.out.println("Result 1 = "+D);
void print ( ) - To print the details as follows:
System.out.println("Result 2 = " +d);
Name of the customer: ………………………
(i) Analyze the given program segment and answer the following questions: [2]
Number of units consumed: ………………………
for(int i=3;i<=4;i++ ) {
Bill amount: ………………………
for(int j=2;j<i;j++ ) {
Write a main method to create an object of the class and call the above member
System.out.print("" ); }
methods.
System.out.println("WIN" ); }
Question 5.
(i) How many times does the inner loop execute?
(ii) Write the output of the program segment. Write a program to accept a number and check and display whether it is a spy number [15]

(j) What is the difference between the Scanner class functions next() and [2] or not. (A number is spy if the sum of its digits equals the product of its digits.)

nextLine()? Example: consider the number 1124, Sum of the digits = 1 + 1 + 2 + 4 = 8


Product of the digits = 1  1  2  4 = 8
T17 861 3 Turn Over T17 861 4
Question 6.
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
(where x = 2)
(ii) To display the following series:
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.

Question 7.
Write a program to input integer elements into an array of size 20 and perform the [15]
following operations:
(i) Display largest number from the array.
(ii) Display smallest number from the array.
(iii) Display sum of all the elements of the array.

Question 8.
Design a class to overload a function check( ) as follows: [15]
(i) void check (String str , char ch ) - to find and print the frequency of a character
in a string.
Example :
Input: Output:
str = "success" number of s present is =3
ch = 's'
(ii) void check(String s1) - to display only vowels from string s1, after converting
it to lower case.
Example :
Input:
s1 ="computer" Output : o u e

Question 9.
Write a program to input forty words in an array. Arrange these words in descending [15]
order of alphabets, using selection sort technique. Print the sorted array.

T17 861 5 T17 861 6


COMPUTER APPLICATIONS Question 2.

(Theory) (a) (i) int res = 'A'; [2]

(Two Hours) What is the value of res?

Answers to this Paper must be written on the paper provided separately. (ii) Name the package that contains wrapper classes.

You will not be allowed to write during the first 15 minutes. (b) State the difference between while and do while loop. [2]

This time is to be spent in reading the question paper. (c) System.out.print("BEST "); [2]

The time given at the head of this Paper is the time allowed for writing the answers. System.out.println("OF LUCK");

Choose the correct option for the output of the above statements
This Paper is divided into two Sections.
(i) BEST OF LUCK
Attempt all questions from Section A and any four questions from Section B.
(ii) BEST
The intended marks for questions or parts of questions are given in brackets[].
OF LUCK

(d) Write the prototype of a function check which takes an integer as an argument [2]
SECTION A (40 Marks) and returns a character.
Attempt all questions
(e) Write the return data type of the following function. [2]

(i) endsWith()
Question 1.
(ii) log()
(a) Define abstraction. [2]

(b) Differentiate between searching and sorting. [2]


Question 3.
(c) Write a difference between the functions isUpperCase( ) and toUpperCase( ). [2] (a) Write a Java expression for the following: [2]

(d) How are private members of a class different from public members? [2] √3𝑥 + 𝑥 2
𝑎+𝑏
(e) Classify the following as primitive or non-primitive datatypes: [2]
(b) What is the value of y after evaluating the expression given below? [2]
(i) char
y+= ++y + y-- + -- y; when int y=8
(ii) arrays
(c) Give the output of the following: [2]
(iii) int
(i) Math.floor (-4.7)
(iv) classes
(ii) Math.ceil(3.4) + Math.pow(2, 3)

This Paper consists of 6 printed pages. (d) Write two characteristics of a constructor. [2]
T18 861 Turn Over
© Copyright Reserved T18 861 2
(e) Write the output for the following: [2] SECTION B (60 Marks)
System.out.println("Incredible"+"\n"+"world"); Attempt any four questions from this Section.
(f) Convert the following if else if construct into switch case [2] The answers in this Section should consist of the Programs in either Blue J environment or any
if( var==1) program environment with Java as the base.
System.out.println("good"); Each program should be written using Variable descriptions/Mnemonic Codes so that the logic
else if(var==2) of the program is clearly depicted.
System.out.println("better"); Flow-Charts and Algorithms are not required.
else if(var==3) Question 4.
System.out.println("best"); Design a class RailwayTicket with following description: [15]
else
Instance variables/data members :
System.out.println("invalid");
String name : To store the name of the customer
(g) Give the output of the following string functions: [2]
String coach : To store the type of coach customer wants to
(i) "ACHIEVEMENT".replace('E', 'A')
travel
(ii) "DEDICATE".compareTo("DEVOTE")
long mobno : To store customer’s mobile number
(h) Consider the following String array and give the output [2]
int amt : To store basic amount of ticket
String arr[]= {"DELHI", "CHENNAI", "MUMBAI", "LUCKNOW",
int totalamt : To store the amount to be paid after updating
"JAIPUR"};
the original amount
System.out.println(arr[0].length()> arr[3].length());
Member methods :
System.out.print(arr[4].substring(0,3));
void accept () – To take input for name, coach, mobile number and amount.
(i) Rewrite the following using ternary operator: [2]
void update() – To update the amount as per the coach selected
if (bill >10000 )
discount = bill * 10.0/100; (extra amount to be added in the amount as follows)
else Type of Coaches Amount
discount = bill * 5.0/100; First_AC 700
Second_AC 500
(j) Give the output of the following program segment and also mention how many [2]
Third_AC 250
times the loop is executed: sleeper None
int i; void display() – To display all details of a customer such as name, coach, total
for ( i = 5 ; i > 10; i ++ ) amount and mobile number.
System.out.println( i );
Write a main method to create an object of the class and call the above member
System.out.println( i * 4 );
methods.

T18 861 3 Turn Over T18 861 4


Question 5. Question 8.

Write a program to input a number and check and print whether it is a Pronic number [15] Write a menu driven program to display the pattern as per user’s choice.
or not. (Pronic number is the number which is the product of two consecutive integers) Pattern 1 Pattern 2 [15]
Examples: 12 = 3  4 ABCDE B
ABCD LL
20 = 4  5 ABC UUU
AB EEEE
42 = 6  7 A
For an incorrect option, an appropriate error message should be displayed.

Question 6. Question 9.

Write a program to accept name and total marks of N number of students in two single [15]
Write a program in Java to accept a string in lower case and change the first letter of [15]
every word to upper case. Display the new string. subscript array name[ ] and totalmarks[ ].

Sample input: we are in cyber world Calculate and print:

Sample output: We Are In Cyber World (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.


Question 7. [deviation = total marks of a student – average]
Design a class to overload a function volume() as follows: [15]

(i) double volume (double R) – with radius (R) as an argument, returns the volume
of sphere using the formula.

V = 4/3  22/7  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  R2  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BH

T18 861 5 Turn Over T18 861 6


COMPUTER APPLICATIONS Question 2.
(a) Differentiate between if else if and switch-case statements. [2]
(Theory)
(b) Give the output of the following code: [2]
(Two Hours)
String P = "20", Q ="19";
Answers to this Paper must be written on the paper provided separately. int a = Integer.parseInt(P);

You will not be allowed to write during the first 15 minutes. int b = Integer.valueOf(Q);
System.out.println(a+""+b);
This time is to be spent in reading the question paper.
(c) What are the various types of errors in Java? [2]
The time given at the head of this Paper is the time allowed for writing the answers.
(d) State the data type and value of res after the following is executed: [2]
This Paper is divided into two Sections. char ch = '9';
Attempt all questions from Section A and any four questions from Section B. res= Character.isDigit(ch);

The intended marks for questions or parts of questions are given in brackets[ ]. (e) What is the difference between the linear search and the binary search [2]
technique?
SECTION A (40 Marks)
Attempt all questions Question 3.
(a) Write a Java expression for the following: [2]
2
| x +2xy |
Question 1.
(a) Name any two basic principles of Object-oriented Programming. [2] (b) Write the return data type of the following functions: [2]
(i) startsWith( )
(b) Write a difference between unary and binary operator. [2]
(ii) random( )
(c) Name the keyword which: [2]
(c) If the value of basic=1500, what will be the value of tax after the following [2]
(i) indicates that a method has no return type. statement is executed?
(ii) makes the variable as a class variable. tax = basic>1200 ? 200 :100;

(d) Write the memory capacity (storage size) of short and float data type in bytes. [2] (d) Give the output of following code and mention how many times the loop will [2]

execute?
(e) Identify and name the following tokens: [2]
int i;
(i) public
for( i=5 ; i>=1 ;i--)
(ii) 'a' {
if(i%2 ==1)
(iii) ==
continue;
(iv) { }
System.out.print( i+ '' '');
}
This Paper consists of 6 printed pages.
T19 861 Turn Over
© Copyright Reserved T19 861 2
(e) State a difference between call by value and call by reference. [2] double amount - To store the amount to be paid after discount

(f) Give the output of the following: [2] Member methods:


Math.sqrt(Math.max(9,16)) ShowRoom( ) - default constructor to initialize data members
(g) Write the output for the following: [2] void input( ) - To input customer name, mobile number, cost
String s1 = ''phoenix''; String s2 =''island'' ; void calculate( ) - To calculate discount on the cost of purchased items, based on
System.out.println (s1.substring(0).concat (s2.substring(2) ) ); following criteria
System.out.println(s2.toUpperCase());
Discount
Cost
(h) Evaluate the following expression if the value of x=2, y=3 and z=1. [2] (in percentage)

v=x+ --z+ y++ +y Less than or equal to ` 10000 5%

(i) String x[] = {"Artificial intelligence", "IOT", "Machine learning", "Big data"}; [2] More than ` 10000 and less than or equal to ` 20000 10%

More than ` 20000 and less than or equal to ` 35000 15%


Give the output of the following statements:
More than ` 35000 20%
(i) System.out.println(x[3]);
void display( ) - To display customer name , mobile number , amount to be paid
(ii) System.out.println(x.length);
after discount.
(j) What is meant by a package? Give an example. [2]
Write a main method to create an object of the class and call the above member
methods.
SECTION B (60 Marks)
Attempt any four questions from this Section.
The answers in this Section should consist of the Programs in either Blue J environment or any Question 5.
program environment with Java as the base. Using the switch-case statement, write a menu driven program to do the following: [15]
Each program should be written using Variable descriptions/Mnemonic Codes so that the logic
(a) To generate and print Letters from A to Z and their Unicode
of the program is clearly depicted.
Flow-Charts and Algorithms are not required. Letters Unicode

A 65
Question 4.
B 66
Design a class name ShowRoom with the following description: [15]
. .
Instance variables / Data members:
. .
String name - To store the name of the customer
long mobno - To store the mobile number of the customer . .
double cost - To store the cost of the items purchased Z 90
double dis - To store the discount amount

T19 861 3 Turn Over T19 861 4


(b) Display the following pattern using iteration (looping) statement: Question 9.

1 A tech number has even number of digits. If the number is split in two equal halves, [15]
1 2 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.
1 2 3

1 2 3 4 Example:

1 2 3 4 5 Consider the number 3025

Square of sum of the halves of 3025 = (30+25)2

= (55)2
Question 6.
Write a program to input 15 integer elements in an array and sort them in ascending [15] = 3025 is a tech number.
order using the bubble sort technique.

Question 7.

Design a class to overload a function series( ) as follows: [15]

(a) void series (int x, int n) – To display the sum of the series given below:

x1 + x2 + x3 + ……………… xn terms

(b) void series (int p) – To display the following series:

0, 7, 26, 63 ……………. p terms

(c) void series ( ) – To display the sum of the series given below:
1 1 1 1
+ + ................
2 3 4 10

Question 8.

Write a program to input a sentence and convert it into uppercase and count and [15]
display the total number of words starting with a letter 'A'.

Example:

Sample Input: ADVANCEMENT AND APPLICATION OF INFORMATION


TECHNOLOGY ARE EVER CHANGING.

Sample Output: Total number of words starting with letter 'A' = 4.

T19 861 5 Turn Over T19 861 6


COMPUTER APPLICATIONS Question 2.
(a) What is autoboxing in Java? Give an example. [2]
(Theory)
(b) State the difference between length and length() in Java. [2]
(Two Hours)
(c) What is constructor overloading? [2]
Answers to this Paper must be written on the paper provided separately.
(d) What is the use of import statement in Java? [2]
You will not be allowed to write during the first 15 minutes.
(e) What is an infinite loop? Give an example. [2]
This time is to be spent in reading the question paper.

The time given at the head of this Paper is the time allowed for writing the answers. Question 3.
(a) Write a Java expression for the following: [2]
This Paper is divided into two Sections.
√𝑏 2 − 4𝑎𝑐
Attempt all questions from Section A and any four questions from Section B.
(b) Evaluate the following if the value of x=7, y=5 [2]
The intended marks for questions or parts of questions are given in brackets [ ].
x+=x++ + x + ++y
SECTION A (40 Marks) (c) Write the output for the following: [2]
Attempt all questions
String s1 = ''Life is Beautiful'';

System.out.println (''Earth'' + s1.substring(4));


Question 1. System.out.println( s1.endsWith(''L'') );
(a) Define Java byte code. [2]
(d) Write the output of the following statement: [2]
(b) Write a difference between class and an object. [2] System.out.println(''A picture is worth \t \''A thousand words.\'' '');
(c) Name the following: [2] (e) Give the output of the following program segment and mention how many times [2]
(i) The keyword which converts variable into constant. the loop will execute:

(ii) The method which terminates the entire program from any stage. int k;

for ( k = 5 ; k < = 20 ; k + = 7 )
(d) Which of the following are primitive data types? [2]
if ( k% 6==0 )
(i) double
continue;
(ii) String
System.out.println ( k );
(iii) char
(f) What is the data type returned by the following library methods? [2]
(iv) Integer
(i) isWhitespace()
(e) What is an operator? Name any two types of operators used in Java. [2]
(ii) compareToIgnoreCase()

This Paper consists of 6 printed pages.


T20 861 Turn Over
© Copyright Reserved T20 861 2

https://www.icseonline.com
(g) Rewrite the following program segment using logical operators: [2] SECTION B (60 Marks)

if ( x > 5 ) Attempt any four questions from this Section.


The answers in this Section should consist of the Programs in either Blue J environment or any
if ( x > y )
program environment with Java as the base.
System.out.println (x+y); Each program should be written using Variable descriptions/Mnemonic Codes so that the logic

(h) Convert the following if else if construct into switch case: [2] of the program is clearly depicted.
Flow-Charts and Algorithms are not required.
if (ch== 'c' || ch=='C')
Question 4.
System.out . print(''COMPUTER'');
A private Cab service company provides service within the city at the following rates: [15]
else if (ch== 'h' || ch=='H')
AC CAR NON AC CAR
System.out . print(''HINDI''); UPTO 5 KM ₹ 150 /- ₹ 120 /-
BEYOND 5 KM ₹ 10/-PER KM ₹ 08/- PER KM
else
Design a class CabService with the following description:
System.out . print(''PHYSICAL EDUCATION''); Member variables /data members:
(i) Give the output of the following: [2] String car_type - To store the type of car (AC or NON AC)
(i) Math.pow (36,0.5) + Math.cbrt (125) double km - To store the kilometer travelled

(ii) Math.ceil (4.2 ) + Math.floor (7.9) double bill - To calculate and store the bill amount

Member methods :
(j) Rewrite the following using ternary operator: [2]
CabService() - Default constructor to initialize data members.
if(n1>n2)
String data members to '' '' and double data
r = true;
members to 0.0.
else
void accept () - To accept car_type and km (using Scanner class
r = false; only).

void calculate () - To calculate the bill as per the rules given above.

void display() - To display the bill as per the following format

CAR TYPE:

KILOMETER TRAVELLED:

TOTAL BILL:

Create an object of the class in the main method and invoke the member methods.

T20 861 3 Turn Over T20 861 4


Question 5. Question 8.

Write a program to search for an integer value input by the user in the sorted list given [15] Write a menu driven program to perform the following operations as per user’s choice: [15]
below using binary search technique. If found display ''Search Successful'' and print (i) To print the value of c=a2+2ab, where a varies from 1.0 to 20.0 with increment
the element, otherwise display ''Search Unsuccessful'' of 2.0 and b=3.0 is a constant.
{31, 36, 45, 50, 60, 75, 86, 90} (ii) To display the following pattern using for loop:

A
Question 6. AB
ABC
Write a program to input a sentence and convert it into uppercase and display each [15]
ABCD
word in a separate line. ABCDE

Example: Input : India is my country Display proper message for an invalid choice.

Output : INDIA
Question 9.
IS
Write a program to input and store integer elements in a double dimensional array of [15]
MY
size 3 x 3 and find the sum of elements in the left diagonal.
COUNTRY
Example:

Question 7. 1 3 5

Design a class to overload a method Number( ) as follows: [15] 4 6 8


(i) void Number (int num , int d) - To count and display the frequency of a 9 2 4
digit in a number.
Output: Sum of the left diagonal elements = (1 + 6 +4) = 11
Example:

num = 2565685

d=5

Frequency of digit 5 = 3

(ii) void Number (int n1) - To find and display the sum of even digits of
a number.

Example:

n1 = 29865

Sum of even digits = 16

Write a main method to create an object and invoke the above methods.

T20 861 5 Turn Over T20 861 6

You might also like