0% found this document useful (0 votes)
62 views5 pages

X ICSE-practice Sheet-1

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)
62 views5 pages

X ICSE-practice Sheet-1

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/ 5

X-ICSE

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.)

(i) Name the feature of java depicted in the adjoining picture.


(a) Abstraction
(b) Encapsulation
(c) Inheritance
(d) Polymorphism
(ii) The expression which uses >= operator is known as:
(a) relational
(b) logical
(c) arithmetic
(d) assignment
(iii) Ternary operator is a/an:
(a) logical operator
(b) arithmetic operator
(c) relational operator
(d) conditional operator
(iv) When primitive data type is converted to a corresponding object of its class, it is called:
(a) Boxing
(b) Unboxing
(c) Explicit type conversion
(d) Implicit type conversion
(v) The number of bytes occupied by a character array of 10 elements.
(a) 60 bytes (c) 20 bytes
(b) 120 bytes (d) 40 bytes
(vi) The method of Scanner class used to accept a character value is:
(a) nextChar()
(b) nextCharacter()
(c) nextLine().charAt(0)
(d) none of these
(vii) Among the following which one is not a keyword:
(a) const (c) for
(b) do (d) while
(viii) Math.sqrt(-1, 0.5) returns:
(a) logical error (c) NaN
(b) syntax error (d) none of these

PRACTICE SHEET- ASHISH 1


(ix) Name the type of error, if any in the following statements:
int a=5, b=0, c=a/b;
(a) Syntax Error
(b) Runtime error
(c) Logical error
(d) No error
(x) Which of the following will extract the middle character of a string (str).
(a) char middle = str.midChar();
(b) char middle = str.charAt(str.length()/2);
(c) char middle = str.charAt(str.length/2);
(d) none of these
(xi) The output of “SJA Prayagraj”.substring(5, 8) is:
(a) Pray (c) ray
(b) raj (d) Pra
(xii) What is the output of the following code snippet:
String one= “One”, two=“”; int three=one.compareTo(two);
(a) -3 (c) 0
(b) 3 (d) none
(xiii) Name the package that contain StringIndexOutOfBoundsException:
(a) java.lang (c) java.util
(b) java.io (d) none
(xiv) Which principle of OOP does ‘extending a class’ adhere to?
(a) Abstraction (c) Inheritance
(b) Encapsulation (d) Polymorphism
(xv) What will be the result of the following statement? System.out.println(3+3 *3* 3+3);
(a) 57 (c) 108
(b) 33 (d) None
(xvi) Which of the following are primitive data types:
i. char ii. Integer iii. float iv. Double
(a) Only i (c) Both i and ii
(b) Only ii (d) All of them
(xvii) Assertion: In Java, the "static" keyword is used to declare variables that belong to the class
and not to instances of the class.
Reason: By using the "static" keyword, these variables can be accessed without
creating an instance of the class.
Which option correctly describes the relationship between Assertion and Reason?
(a) Both Assertion and Reason are true, and Reason is a correct explanation of Assertion.
(b) Both Assertion and Reason are true, but Reason is not a correct explanation of Assertion.
(c) Assertion is true, but Reason is false.
(d) Assertion is false, but Reason is true.
(xviii) Read the following text, and choose the correct answer:
In Java, the "for" statement is used to loop till a given condition is true. Which of the
following is true about the "for" statement in Java?
(a) Initialization in for is optional
(b) Condition in for is optional.
(c) Increment/Decrement i.e. step is optional.
(d) All of the above.

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]

(i) Write the Java expression for y=b+√(b²-4ac))/(2a)


(ii) Evaluate the expression when int x=2:
int y=x+x++ + ++x+x;
(iii) The following code segment checks if the given year is a leap year or not.
[However the code has errors. Fix the code so that it compiles and runs correctly.]
public static booleanisOdd(int n){
boolean result = False; if (n%2==1)
result=true; return result;
}
(iv) Harsh is trying to determine the average of three numbers.
However, the following code segment is not giving the correct answer. How the program can be
modified to get the correct answer?
Scanner in = new Scanner( System.in );
float number1=in.nextFloat();
float number2=in.nextFloat();
float number2=in.nextFloat();
float average=number1 + number2 + number3 / 3;
System.out.println(“Average is “, average);

(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

PRACTICE SHEET- ASHISH 3


String zero = “0”;
String zeros = “0000”;
String nothing = “ ”;
System.out.println((nothing+zeros.length()*zero.length()).length());
(ix) When there is no explicit initialization, what is the default values set for variable in the
following cases?
i. Double ii. Boolean
(x) How is a break different from continue?

SECTION B (60 Marks)


(Answer any four questions from this Section.)
The answers in this section should consist of the programs in either BlueJ environment or
any program environment with java as the base.
Each program should be written using variable description/mnemonic codes so that the logic
of the program is clearly depicted.
Flowcharts and algorithms are not required.

Question 3. [ 15 ]
Design a class Bus_Ticket with following description:

Instance variables/s data members:

String name : To store the name of the customer


String type : To store the type of reservation, 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, 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.

PRACTICE SHEET- ASHISH 4


Example for n=3:
1
23
456
void triangle(String text): This version of the method should take a string 'text' and display a
triangle pattern using the provided string.
For example text=”SJA”
S
SJ
SJA
Question 5. [ 15 ]
A number is Dudney if the cube of the sum of digits is equal to the number.
Design a Java program that takes an integer as input and checks whether it is a Dudney
Number or not. If the number entered is negative display “Invalid Input”.
Example: 512
5+1+2=8 => 83=512, 8 is a dudney number

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.

PRACTICE SHEET- ASHISH 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy