X ICSE-practice Sheet-1
X ICSE-practice Sheet-1
COMPUTER APPLICATIONS
Maximum Marks: 100 Time: allowed: Two Hours
Answers to this paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 minutes.
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.
This paper is divided into two sections.
You are to answer 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 [ ].
SECTION A ( 40 Marks )
(Attempt all questions)
Question 1. [ 20 ]
Choose the correct answers to the questions from the given options.
(Do not copy the question, write the correct answers only.)
2
(xix) Assertion: In Java, the "equals" method is used to compare the content of two String objects
for equality.
Reason: The "equals" method in the String class is overridden to compare the content of the
strings, not just their references in memory.
(a) Both the assertion and reason are correct, and the reason is a correct explanation of the
assertion.
(b) Both the assertion and reason are correct, but the reason is NOT a correct explanation of the
assertion.
(c) The assertion is correct, but the reason is incorrect.
(d) The assertion is incorrect.
(xx) Which of the following statements correctly describes the behaviour of the Math.random()
method in Java?
(a) Math.random() returns a random integer between 0 (inclusive) and 1 (exclusive).
(b) Math.random() returns a random double between 0.0 (inclusive) and 1.0 (exclusive).
(c) Math.random() generates a random boolean value.
(d) Math.random() returns a random long value.
Question 2. [20]
(v)What will be the value of count after the following code segment is executed?
byte count = 0;
for( ;count>=0; ){
count++;
}
(vi) What is the output (value returned) of the following
System.out.println (“ABCDEFGHIJKMNOPQRSTUVWXYZ”.lastIndexOf(‘Z’));
System.out.println (“aeiouAEIOU”.indexOf(‘l’)>=0);
(vii) Name the two reserved words which are not keywords.
(viii) Predict the output of the following code snippet
Question 3. [ 15 ]
Design a class Bus_Ticket with following description:
Member methods
void accept ( ) : To take input for name, type, mobile number and amount
void update ( ) : To update the amount as per the type selected
Type Amount
AC_Delux 700
AC_Executive 500
AC_Sleeper 250
Sleeper 100
void display( ) — To display all details of a customer sch as name, type, total amount and mobile
number.
Write a main method to create an object of the class and call the above member methods.
Question 4. [15
]
Create a Java program that overloads the triangle() method to display a triangle pattern. The method
should have two variants:
void triangle(int n): This version of the method should take an integer 'n' and display a triangle
pattern of 'n' rows.
Question 6 [ 15 ]
Write a program to prompt the user to create and load an of size M x N, where M and
N are provided by the user at runtime. Compute and display the sum of boundary and
non-boundary elements separately.
Question 7. [15 ]
Write a program to enter a string, convert it in to uppercase character and print that word
only which has same character in starting and ending.
Question 8. [ 15 ]
Write a Java program to create an array to store N numbers and determine whether the array
is sorted in ascending order or not. Your program should take user input for the number of
elements (N) and the array values. Then, it should check if the elements in the array are
arranged in ascending order. If they are, the program should output that the array is sorted in
ascending order; otherwise, it should display that the array is not sorted in ascending order.