Professional Documents
Culture Documents
Sample Solutions To ICSE Paper #1
Sample Solutions To ICSE Paper #1
(e) State any two advantages of if else construct over switch case.
Ans: The two advantages of the if-else construct over the switch case are:
(i) The if-else construct can handle a range of values whereas switch case can handle only single
values.
(ii) The if-else construct can evaluate expressions of any type whereas switch case can evaluate
expressions of int, char and String type only.
(iii) The if-else construct supports the use of all rela�onal operators (>, <, >=, <= and ==) whereas the
switch statement works by comparing the switch expression with the case values for equality.
Ques�on #2.
(c) Consider the following elements:
638421
Show how the following elements will appear a�er each pass of Bubble sort.
Ans: When sorted in ascending order, the arrangement of the array elements are as follows:
A�er Pass 1:
364218
A�er Pass 2:
342168
A�er Pass 3:
321468
A�er Pass 4:
213468
A�er Pass 5:
123468
Thus, the array elements get sorted in ascending order a�er 5 passes of the Bubble sort algorithm.
Ques�on 3.
(e) Dis�nguish between call by value and call by reference. [two differences in tabular order]
Call by value Call by reference
1. In this type of a func�on call, only the values In this type of func�on call, the reference
of the variables are sent to the calling func�on. to the actual arguments are sent to the
calling func�on.
2. In this type of func�on call, any changes made In this type of call, any changes made to the
inside the func�on do not affect the original values func�on parameter(s) inside the func�on
of the variables. will affect the values of the original
variables.
(h) State the use of the keyword new.
Ans: The new keyword in Java, is used for:
(i) Crea�ng object of a class.
(ii) Allocate memory for the array.
(i) What is polymorphism? How does Java implement polymorphism? Explain briefly.
Ans: Polymorphism is one of the four fundamental principles of Object-Oriented Programming (OOP). It
refers to the ability of a variable, func�on, or object to take on mul�ple forms.
In Java, polymorphism is implemented in two ways: Method overloading and Method overriding.
1. Method overloading is when mul�ple methods have the same name but different parameters.
2. Method overriding is when a subclass provides a specific implementa�on of a method that is already
provided by its parent class.