Comp App Practise 6 Papers
Comp App Practise 6 Papers
(Theory)
(Two Hours)
The time given at the head of this Paper is the time allowed for writing the answers.
Attempt all questions from Section A and any four questions from Section B.
The intended marks for questions or parts of questions are given in brackets[].
Question 1.
(a) Define encapsulation. [2]
(b) Explain the purpose of using a ‘new’ keyword in a Java program. [2]
Question 2.
(b) Rewrite the following condition without using logical operators: [2]
if ( a>b || a>c )
System.out.println(a);
(c) Rewrite the following loop using for loop: [2]
while (true)
System.out.print("*");
(d) Write the prototype of a function search which takes two arguments a string [2]
and a character and returns an integer value.
Question 3.
(a) State the number of bytes and bits occupied by a character array of 10 elements. [2]
(b) Differentiate between Binary Search and Linear Search techniques. [2]
(f) What is the value of m after evaluating the following expression: [2]
m - = 9%++n + ++n/2; when int m=10,n=6
(i) Math.pow(25,0.5)+Math.ceil(4.2)
(i) "TRANSPARENT".toLowerCase();
(ii) "TRANSPARENT".compareTo("TRANSITION")
(i) Write a java statement for each to perform the following task: [2]
(i) Find and display the position of the last space in a string str.
(ii) System.out.println(100/0);
Question 4.
Anshul transport company charges for the parcels of its customers as per the following [15]
specifications given below:
void print ( ) – to print the name of the customer, weight of the parcel, total bill
inclusive of surcharge in a tabular form in the following format :
Define a class with the above-mentioned specifications, create the main method,
create an object and invoke the member methods.
Question 5.
Write a program to input name and percentage of 35 students of class X in two separate [15]
one dimensional arrays. Arrange students details according to their percentage in the
descending order using selection sort method. Display name and percentage of first
ten toppers of the class.
Question 6.
(i) int Sum(int A, int B) – with two integer arguments (A and B) calculate and return
sum of all the even numbers in the range of A and B.
(ii) double Sum( double N ) – with one double arguments(N) calculate and return
the product of the following series:
(iii) int Sum(int N) - with one integer argument (N) calculate and return sum of only
odd digits of the number N.
Write the main method to create an object and invoke the above methods.
Question 7.
Using the switch statement, write a menu driven program to perform following [15]
operations:
3
(i) To Print the value of Z where Z = 𝑥 +0.5𝑥 where x ranges from – 10 to 10 with
𝑌
Example: If N = 5, Output:
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Question 8.
Write a program to input and store integer elements in a double dimensional array of [15]
size 4×4 and find the sum of all the elements.
7 3 4 5
5 4 6 1
6 9 4 2
3 2 7 5
Example:
Input:
Output :
Paper 2
Choose the correct answers to the questions from the given options. (Do not copy the
question, Write the correct answer only.) [10]
(i) When primitive data type is converted to its corresponding object of its class, it is
called as .
(a) Boxing
char x='7';
y= Character.isLetter(x);
(a) false
(b) 7
(c) true
(d) ‘7’
(iii) Give the output of the following string methods:
"MISSISSIPPI".indexOf('S')+ "MISSISSIPPI".lastIndexOf('I')
(a) 10
(b) 12
(c) 20
(d) 11
(a) integer
(b) INTEGER
(c) Int
(d) Integer
(v) Variable that is declared with in the body of a method is termed as:
(a) private
(b) public
(c) protected
(d) package
System.out.println((C+D));
(a) 26
(b) 74
(c) 100.0
(d) 2674
(a) java.io
(b) java.util
(c) java.lang
(d) java.awt
SECTION B
Question 2 [10]
Define a class to declare an integer array of size n and accept the elements into the array.
Search for an element input by the user using linear search technique, display the element
if it is found, otherwise display the message “NO SUCH ELEMENT.
Question
3
[10]
Define a class to declare a character array of size ten, accept the character into
the arrayand perform the following:
Question
4
[10]
Question
5
[10]
Define a class to accept two strings, convert them into uppercase, check and
display whether two strings are equal or not, if the two strings are not equal, print
the string with the highest length or print the message both the strings are of equal
length.
Question
6
[10]
Define a class to accept a string, convert it into lowercase and check whether
the string isa palindrome or not.
A palindrome is a word which reads the same backward
as forward.Example:
Question
7
[10]
Define a class to accept and store 10 strings into the array and print the strings
with evennumber of characters.
Paper 3
Sample Paper 4
Sample Papers ICSE Class 10 Computer
Applications
Section A
Question 1
1. double
2. String
3. char
4. Integer
Question 2
Question 3
x += x++ + x + ++y
int k;
for ( k = 5 ; k < = 20 ; k + = 7 )
if ( k% 6==0 )
continue;
System.out.println(k);
(f) What is the data type returned by the following library methods?
1. isWhitespace()
2. compareToIgnoreCase()
Answer
1. boolean
2. int
1. Math.pow(36,0.5) + Math.cbrt(125)
2. Math.ceil(4.2) + Math.floor(7.9)
if(n1>n2)
r = true;
else
r = false;
Section B
Question 4
₹08/- PER
Beyond 5 KM ₹10/- PER KM
KM
Member methods:
void calculate() — To calculate the bill as per the rules given above.
CAR TYPE:
KILOMETER TRAVELLED:
TOTAL BILL:
Create an object of the class in the main method and invoke the
member methods.
Question 5
{75, 86, 90, 45, 31, 50, 36, 60, 12, 47}
Question 6
Example:
Question 7
(i) void Number(int num, int d) — To count and display the frequency
of a digit in a number.
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 = 2 + 8 + 6 = 16
Question 8
(i) To print the value of c=a²+2ab, where a varies from 1.0 to 20.0
with increment of 2.0 and b=3.0 is a constant.
A
AB
ABC
ABCD
ABCDE
Sample Paper 5
Section A
Question 1
1. true
2. 'X'
3. "false"
4. 25.75
(e) Name the wrapper classes of char type and long type
Question 2
(d) Write the prototype of a function check which takes a String and
a character as an argument and returns a boolean.
Question 3
2 2
√ (x-h) + (y-k)
a b
Answer
Math.sqrt((Math.pow((x-h), 2) / a) + Math.pow((y-k), 2) / b)
(b) Give the output of the following:
1. Math.max(Math.ceil(14.5), 15.5)
2. Math.sqrt(Math.abs(-225))
m -= 9 % ++n + ++n / 2
tax = income > 1000000 ? income * 30.0 / 100 : income * 10.0 / 100;
(e) Give the output of the following program segment:
int f=1, i;
for(i=1; i<=5; i++)
f*=i;
System.out.println(f);
(g) Give the output of the following program segment:
Section B
Question 4
Member methods:
void display() — To display the employee name, salary and all salary
components.
Write a main method to create object of the class and call the
member methods.
Question 5
Example:
Sum of digits = 5 + 1 + 2 = 8
Cube root of 512 = 8
Question 6
(a)
1234567
12345
123
1
(b)
11111
22222
33333
44444
55555
Question 7
(a) void series(int a, int n) — To display the sum of the series given
below:
(b) void series(int n) — To display the sum of the series given below:
Question 8
Question 9
Question 1
(a) What are the differences between Procedural Programming and Object-Oriented
Programming?
1. Scanner class
2. Wrapper classes
Question 2
Question 3
√m(ah+v2)
2
z *= ++x * (y--) - y
if (a == 10)
System.out.println("TEN");
else if (a == 50)
System.out.println("FIFTY");
else if (a == 100)
System.out.println("HUNDRED");
else
System.out.println("UNKNOWN");
(e) Rewrite the following program segment using for loop:
int n = 152, s = 0;
while (n != 0) {
int d = n % 10;
s = s + d;
n = n / 10;
}
(f) Rewrite the following program segment using ternary operator:
if (m == 0)
System.out.println("Hello");
else
System.out.println("Good Day");
(g) What is a fall through? Give an example.
(h) Give the output of the following program segment and also mention the number of
times the loop is executed:
int x, y;
for (x = 9, y = 4; x <= 45; x+=9) {
if (x % y == 0)
break;
}
System.out.println(x);
(i) Consider the below function:
void strop(String s) {
char a = s.charAt(3);
int b = s.indexOf('M');
String t = s.substring(3,6);
boolean p = s.equals(t);
System.out.println(a + " " + b + " " + t + " " + p);
}
What will be the output for strop("COMPUTER")?
(j) Give the output of the following program segment:
System.out.println("nine:" + 5 + 4);
System.out.println("nine:" + (5 + 4));
Section B
Question 4
char cardType — Type of card, 'P' for Platinum, 'G' for Gold, 'S' for Silver.
Member methods:
Customer(String name, long num, char type, double amt) — Parameterised constructor
to initialize all data members.
Write a main method to input the card details from the user then create object of the
class and call the member methods with the provided details.
Question 5
Using switch-case statement write a menu driven program for the following:
Question 6
Write a program to input and store roll number and total marks of 20 students. Using
Bubble Sort technique generate a merit list. Print the merit list in two columns
containing roll number and total marks in the below format:
Question 7
Write a class with the name Area using function overloading that computes the area of
a parallelogram, a rhombus and a trapezium.
Formula:
Write a main method to create an object and invoke the above methods.
Question 8
Write a program to print the sum of negative numbers, sum of positive even numbers
and sum of positive odd numbers from a list of numbers entered by the user. The list
terminates when the user enters a zero.
Question 9
Write a program to take a number from the user as input. Find and print the largest
digit of the number.
Example: