ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
Question 1- Give one example each of a primitive data type and a composite data type.
Ans. Primitive Data Types – byte, short, int, long, float, double, char, boolean
Composite Data Type – Class, Array, Interface
Question 2- Give one point of difference between unary and binary operators.
Ans. A unary operator requires a single operand whereas a binary operator requires two
operands.
Examples of Unary Operators – Increment ( ++ ) and Decrement ( — ) Operators
Examples of Binary Operators – +, -, *, /, %
Question 3- Differentiate between call by value or pass by value and call by reference or
pass by reference.
Ans. In call by value, a copy of the data item is passed to the method which is called whereas in
call by reference, a reference to the original data item is passed. No copy is made. Primitive types
are passed by value whereas reference types are passed by reference.
Question 5- Name the types of error (syntax, runtime or logical error) in each case given
below:
(i) Division by a variable that contains a value of zero.
(ii) Multiplication operator used when the operation should be division.
(iii) Missing semicolon.
Ans.
(i) Runtime Error
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 1/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
(ii) Logical Error
(iii) Syntax Error
Question 6- Create a class with one integer instance variable. Initialize the variable using:
Ans.
public class Integer
{
int x;
public Integer() {
x = 0;
}
Question 10- Differentiate between public and private modifiers for members of a class.
Ans. Variables and Methods whwith the public access modie the class also.
Question 11- Question - What are the values of x and y when the following statements are
executed?
int a = 63, b = 36;
boolean x = (a < b ) ? true : false; int y= (a > b ) ? a : b ;
Ans. x = false
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 2/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
Ans. x false
y = 63
int n = c + 1;
Ans. The ASCII value for ‘A’ is 65. Therefore, n will be 66.
Question 13- What will be the result stored in x after evaluating the following
expression?
int x=4;
x += (x++) + (++x) + x;
Ans. x = x + (x++) + (++x) + x
x=4+4+6+6
x = 20
String s = "Examination";
int n = s.length();
System.out.println(s.startsWith(s.substring(5, n)));
System.out.println(s.charAt(2) == s.charAt(6));
Ans.
false
true
Explanation : n = 11
s.startsWith(s.substring(5, n)) = s.startsWith ( “nation” ) = false
( s.charAt(2) == s.charAt(6) ) = ( ‘a’== ‘a’ ) = true
Question 17- State the data type and values of a and b after the following segment is
executed.
String s1 = "Computer", s2 = "Applications";
a = (s1.compareTo(s2));
b = (s1.equals(s2));
Ans. Data type of a is int and b is boolean.
ASCII value of ‘C’ is 67 and ‘A’ is 65. So compare gives 67-65 = 2.
Therefore a = 2
b = false
Question 19- Rewrite the following program segment using while instead of for
statement
int f = 1, i;
for (i = 1; i <= 5; i++)
{
f *= i;
System.out.println(f);
}
Ans.
int f = 1, i = 1;
while (i <= 5)
{
f *= i;
System.out.println(f);
i++;
Question 20- Inthe program given below, state the name and the value of the
(i) method argument or argument variable
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 4/22
7/22/2020
() g g
ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
class myClass {
static int x = 7;
int y = 2;
void sampleMethod(int n) {
System.out.println(n);
System.out.println(y);
}
}
Question 21- What is meant by precedence of operators? Ans. Precedence of operators refers to the
order in which the operators are applied to the operands in an expression. For example, * has higher
precedence than +. So, the expression 8 + 2 * 5 will evaluate to 8 + 10 = 18
Question 22- What is a literal? Ans. A literal is a constant data item. There are different literals like
integer literals, floating point literals and character literals.
Question 23- State the Java concept that is implemented through: i) a super class and a subclass. ii)
the act of representing essential features without including background details. Ans. i) Inheritance ii)
Abstraction.
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 5/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
Question 24- Give a difference between constructor and method. Ans. i)A constructor has no return
type which a method has a return type. ii) The name of the constructor should be the same as that of the
class while the name of a method can be any valid identifier. iii) A constructor is automatically called upon
object creation while methods are invoked explicitly.
Question 25- What are the types of casting shown by the following examples? i) double x =15.2; int
y =(int) x; ii) int x =12; long y = x; Ans. i) Explicit casting ii) Implicit casting
Question 26- Name any two wrapper classes. Ans. Byte, Short, Integer, Long, Float, Double, Boolean,
Character
Question 27- What is the difference between break and continue statements when they occur in a
loop. Ans. The break statement terminates the loop while the continue statements current iteration of the
loop to be skipped and continues with the next iteration.
Question 28- Write statements to show how finding the length of a character array and char[]
differs from finding the length of a String object str. Ans. The length of a character array is found by
accessing the length attribute of the array as shown below: char[] array = new char[7]; int
lengthOfCharArray = array.length; The length of a String object is found by invoking the length() method
which returns the length as an int. String str = “java”; int lengthOfString = str.length();
Question 29- Name the Java keyword that: (i) indicates a method has no return type. (ii) stores the
address of the currently calling object. Ans. i) void ii) this
Question 30- What is an exception? Ans. An exception is an unforeseen situation that occurs during the
execution of a program. In simpler words, they are the errors that occur during the execution of a program.
The JRE throws an Exception object to indicate an exception which contains the information related to that
exception.
Question 31- Write Java statement to create an object mp4 of class digital. Ans. digital mp4 = new
digital();
Question 32- State the values stored in variables str1 and str2
String s1 = "good";
Ans. s2.substring(5) gives ” matters”. When ‘t’ is replaced with ‘n’, we get ” manners”. “good” when
concatenated with ” manners” gives “good manners”. So, str1 = ” manners” and str2 = “good manners”.
Question 33- What does a class encapsulate? Ans. A class encapsulated the data (instance variables)
and methods.
Question 34- Rewrite the following program segment using the if..else statement. comm =
(sale>15000)?sale*5/100:0; Ans.
} else {
comm = 0;
Question 35- How many times will the following loop execute? What value will be returned?
int x = 2, y = 50;
do{
++x;
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 7/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
y-=x++;
}while(x<=10);
return y;
Ans. In the first iteration, ++x will change x from 2 to 3. y-=x++ will increase x to 4. And y becomes 50-
3=47. In the second iteration, ++x will change x from 4 to 5. y-=x++ will increase x to 6. And y becomes
47-5=42. In the third iteration, ++x will change x from 6 to 7. y-=x++ will increase x to 8. And y becomes
42-7=35. In the fourth iteration, ++x will change x from 8 to 9. y-=x++ will increase x to 10. And y
becomes 35-9=26. In the fifth iteration, ++x will change x from 10 to 11. y-=x++ will increase x to 12. And
y becomes 26-11=15. Now the condition x<=10 fails. So, the loop executes five times and the value of y
that will be returned is 15.
Question 36- What is the data type that the following library functions return? i) isWhitespace(char
ch) ii) Math.random() Ans. i) boolean ii) double
Question 37- Write a Java expression for ut + ½ ft2 Ans. u * t + 0.5 * f * Math.pow ( t, 2)
Question 38- If int n[] ={1, 2, 3, 5, 7, 9, 13, 16} what are the values of x and y?
x=Math.pow(n[4],n[2]);
y=Math.sqrt(n[5]+[7]);
Ans.
n[4] is 7 and n[2] is 3. So, Math.pow(7,3) is 343.0. n[5] is 9 and n[7] is 16. So Math.sqrt(9+16) will give
5.0. Note that pow() and sqrt() return double values and not int values.
Question 39- What is the final value of ctr after the iteration process given below, executes?
int ctr=0;
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 8/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
for(int i=1;i<=5;i++)
for(int j=1;j<=5;j+=2)
++ctr;
Ans.
Outer loop runs five times. For each iteration of the outer loop, the inner loop runs 3 times. So, the
statement ++ctr executes 5*3=15 times and so the value of ctr will be 15.
Question 40- Name the methods of Scanner class that: i) is used to input an integer data from
standard input stream. ii) is used to input a string data from standard input stream. Ans. i)
scanner.nextInt() ii) scanner.next()
Question 41. What is the difference between an object and a class? Ans. 1. A
class is a blueprint or a prototype of a real world object. It contains instance
variables and methods whereas an object is an instance of a class. 2. A class exists
in the memory of a computer while an object does not. 3. There will be only one
copy of a class whereas multiple objects can be instantiated from the same class.
Question 42. What does the token ‘keyword’ refer to in the context of Java?
Give an example for keyword. Ans. Keywords are reserved words which convey
special meanings to the compiler and cannot be used as identifiers. Example of
keywords : class, public, void, int
Question 43. State the difference between entry controlled loop and exit
controlled loop. Ans. In an entry controlled loop, the loop condition is checked
before executing the body of the loop. While loop and for loop are the entry
controlled loops in Java. In exit controlled loops, the loop condition is checked
after executing the body of the loop. do-while loop is the exit controlled loop in
Java.
Question 44. What are the two ways of invoking functions? Ans. If the function is
static, it can be invoked by using the class name. If the function is non-static, an
object of that class should be created and the function should be invoked using
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 9/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
object of that class should be created and the function should be invoked using
that object.
Question 45. What is difference between / and % operator? Ans. / is the division
operator whereas % is the modulo (remainder) operator. a / b gives the result
obtained on diving a by b whereas a % b gives the remainder obtained on diving a
by b.
Question 46. State the total size in bytes, of the arrays a [4] of char data type
and p [4] of float data type. Ans. char is two bytes. So a[4] will be 2*4=8 bytes.
float is 4 bytes. So p[4] will be 4*4=16 bytes.
Question 47. (i) Name the package that contains Scanner class. (ii) Which unit
of the class gets called, when the object of the class is created? Ans. (i) java.util
(ii) Constructor
System.out.println(n.endsWith(“e”));
ComputerApplications
true
Question 49. (d) Write the output of the following: (i) System.out.println
(Character.isUpperCase(‘R’)); (ii)
System.out.println(Character.toUpperCase(‘j’)); Ans. (i) true (ii) J
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 10/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
Question 50. (e) What is the role of keyword void in declaring functions?
Ans. void indicates that the function doesn’t return any value.
Question 51. Analyse the following program segment and determine how many
times the loop will be executed and what will be the output of the program
segment ?
int p = 200;
while(true)
if (p<100)
break;
p=p-20;
System.out.println(p);
Ans.p values changes as follows : 200, 180, 160, 140, 120, 100, 80. So, the loop
executes six times and value of p is 80.
Question 52. What will be the output of the following code? (i)
int k = 5, j = 9;
k += k++ – ++j + k;
Ans.
k=6
j = 10
double b = -15.6;
Ans.
a = 16.0
class Age
{
}
{
}
Question 55. Give the prototype of a function search which receives a sentence
sentnc and a word wrd and returns 1 or 0 ? [2] Ans.
or
z = ( 5 * Math.pow ( x, 3 ) + 2 * y ) / ( x + y )
Question 57. Write a statement each to perform the following task on a string:
(i) Find and display the position of the last space in a string s. (ii) Convert a
number stored in a string variable x to double data type Ans. (i)
System.out.println(s.lastIndexOf(” “); (ii) Double.parseDouble(x)
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 13/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
Question 58. Name the keyword that: (i) informs that an error has occurred in
an input/output operation. (ii) distinguishes between instance variable and class
variables. Ans. (i) throw (ii) static
Question 60. Write one difference between Linear Search and Binary Search .
Ans. Linear search can be used with both sorted and unsorted arrays. Binary search
can be used only with sorted arrays.
Ans. The Java compiler compiles the source programs into an intermediate code
called the Java Byte Code which is interpreted by the Java Virtual Machine (JVM)
Ans. Type conversion or casting is the conversion of the data type of a literal from
one type to another. There are tow types of types of casting – implicit casting and
explicit casting.
Ans. break and continue are the two jump statements in Java. break is used to
force early termination of a loop. continue is used to move to the next iteration of
the loop while skipping the remaining code in the current iteration.
Ans. An Exception is an error which occurs during the execution of a program. The
exception handling blocks are try, catch and finally.
Question 66- State the purpose and return data type of the following String
functions:
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 14/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
(i) indexOf ( )
(ii) compareTo ( )
Ans. i) indexOf() returns the index of the character or String passed as the
parameter in the string on which is invoked.
Question 67- What is the result stored in x, after evaluating the following
expression
int x = 5;
x = x++ * 2 + 3 * –x;
Ans. x = 5 * 2 + 3 * -6
x = 10 – 18
x = -8
Ans. i) static variables belong to the class and all object share a single instance of
the static variables. Non static varaiables belong to the objects. Each object has a
copy of these members.
ii) static functions can access only static data members. Non static function can
access both static and non static data members.
Question 69- Write the difference between length and length() functions.
Ans. length is a property of an array which gives the size of the array. length() is a
function of the String class which returns the size of the String.
Ans. private members are accessible only in the class in which they have been
defined. protected members are accessible in the class in which they have been
defined as well in the sub classes of that class.
int m=2;
int n=15;
m++; –-n;
System.out.println("m=" +m);
System.out.println("n="+n);
Ans.
m=3
n=14
Note that there is a semicolon at the end of the loop. So, it is an empty loop and
does’t affect the values of m and n.
System.out.println("m="+m);
Ans.
m=97
Question 74- Analyse the following program segment and determine how many
times the loop will be executed and what will be the output of the program
segment.
while (++i<6)
k*=i;
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 16/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
k i;
System.out.println(k);
3 < 6 ---- k = 1 * 3 = 3
4 < 6 ---- k = 3 * 4 = 12
5 < 6 ---- k = 12 * 5 = 60
60
Question 75- Give the prototype of a function check which receives a character
ch and an integer n and returns true or false.
Ans.
Question 77- Write a statement each to perform the following task on a string:
Extract the second last character of a word stored in the variable wd.
Ans.
char ch = wd.charAt(wd.length()-2);
Ans.
iscandicseboardqa.blogspot.com/2018/02/icse-class-10-computer-application.html 17/22
7/22/2020 ICSE Class 10 - Computer Application Important Questions & Answers (2 Marks)
Question 79- What will the following functions return when executed?
(ii) Math.ceil(7.8)
Ans. i) -17
ii) 8.0
ii) The import keyword is used to import classes from external packages.