[go: up one dir, main page]

0% found this document useful (0 votes)
29 views11 pages

Forms and Circulars

These are forms and circulars for studies

Uploaded by

spsr953
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)
29 views11 pages

Forms and Circulars

These are forms and circulars for studies

Uploaded by

spsr953
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/ 11

Model Test Paper 14 (Solved)

Maximum Marks: 100

n
Time allowed: Two hours
Answers to this Paper must be written on the paper provided separately.

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

as
This Paper is divided into two Sections.
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 [ ].

ak
SECTION A

Pr
(Attempt all questions from this Section)
Question 1 [20]
Choose the correct answers and write the correct option.
(i) ______________variable is visible/usable within the method that it has been declared in.
rs
(a) A class (b) A local (c) A primitive (d) An object
(ii) What is the output of the following code?
he

char c = ‘B’;
int i = 4;
System.out.println(c+i);
System.out.println((int)c + i);
ot

(a) 70 (b) 68 (c) 98 (d) 102


70 68 98 102
Br

(iii) What do you mean by encapsulation?


(a) A method of combining data and its associated functions in the form of single unit
(b) Use of only one function and multiple class variables
(c) Use of only one class variable and multiple methods
al

(d) None of these


(iv) For the below code, give the output.
String str = “It is need of the hour”;
oy

System. out .println (“substring \”hour\”:” + str.indexOf(“hour”));


(a) 18 (b) 19 (c) 20 (d) 21
(v) What is the value returned by the following line in Java?
G

Math.ceil(6.8)
(a) 8.0 (b) 9.0 (c) 7.0 (d) 6.0
(vi) Which is the first method called when a stand-alone Java application is started?
(a) Class constructor with the name as Java file (b) main
(c) First class declared in the file, its constructor (d) None of these
Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10 93
(vii) Class modifiers are used to specify two aspects of classes:
(a) Access and type (b) Modifier and type
(c) Access and Modify (d) None of these
(viii) The data in an object are called its ____________fields, and the procedures that operate on the data are called
its ______________.
(a) Methods, Classes (b) Classes, libraries (c) Instance, methods (d) None of these
(ix) Out of the following options, name the reference datatype.

n
(a) Object (b) Array (c) Float (d) Char

ha
(x) What would the following code do?
index = text.lastIndexOf(‘a’);
(a) Find first index position containing ‘a’ (b) Find last index position containing ‘a’

as
(c) Find first index position of any character (d) Find last index position of any character
(xi) Which of the following statement(s) is/are TRUE?
(a) Inheritance provides programming by extension as opposed to programming by reinvention.Inheritance

ak
allows explicitly taking advantage of the commonality of objects when constructing new classes.
(b) Inheritance is a relationship between classes where one class is the parent class of another (derived) class.
(c) Both (a) and (b)

Pr
(d) None of these
(xii) Find the output of the following if the values of the variables are x = 2, y = 3 and z = 9.
x*(++y)%z
(a) 7 (b) 8 (c) 9 (d) 10
rs
(xiii) Assertion(A): Java has function to return whether a character is a whitespace.
Reason (R): The static boolean isWhiteSpace(char ch) function is such a function.
he

(a) Both Assertion (A) and Reason (R) are true and Reason(R) is a correct explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason(R) is not a correct explanation of Assertion (A)
(c) Assertion (A) is true and Reason(R) is false
ot

(d) Assertion (A) is false and Reason (R) is true


(xiv) Read the following text, and choose the correct answer:
Br

The expression is of the form:


Boolean-exp ? value0 : value1
If Boolean-exp evaluates to true, value0 is evaluated and its result becomes the value produced by the operator.
If Boolean-exp is false, value1 is evaluated and its result becomes the value produced by the operator.
al

In the ternary operator, if the Boolean-exp evaluates to true, then which expression is evaluated?
(a) Value0 (b) Value1
oy

(c) Boolean-exp (d) None of these


(xv) Assertion(A): The return keyword has two purposes.
Reason (R): It specifies what value a method returns (if it does not have a void return value) and it causes
G

that value to be returned immediately.


(a) Both Assertion (A) and Reason (R) are true and Reason(R) is a correct explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason(R) is not a correct explanation of Assertion (A)
(c) Assertion (A) is true and Reason(R) is false
(d) Assertion (A) is false and Reason (R) is true

94 Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10
(xvi) What does { } signifies?
(a) Scope of the instance variable (b) Scope of the class variables
(c) Both (a) and (b) (d) None of these
(xvii) An arithmetic expression can contain a mix of:
(a) Literals (b) Variables
(c) Subscripted variables (d) All of these
(xviii) If you pass the object as an argument to a function for updation, what kind of argument passing is it

n
known as?

ha
(a) Pass by value (b) Pass by reference
(c) Pass by argument (d) None of these
(xix) If you find a this() within a method in Java, what is it supposed to mean?
(a) The calling object’s constructor is being invoked

as
(b) The calling object is being referred to
(c) The function named as this() is being referred to
(d) The second argument in the method is being referred to

ak
(xx) Lalit was using his toLowerCase() method in the following way, but it was giving error. What is the correct
way to invoke this method?
char c = toLowerCase(‘A’);

Pr
(a) char c = ‘A’.toLowerCase(); (b) char c = ‘A’→toLowerCase();
(c) char c = ‘A’→toLowerCase() ; (d) String c = “A”.toLowerCase();

ANSWERS
rs
(i) (b) (ii) (a) (iii) (a) (iv) (a) (v) (c) (vi) (b) (vii) (b) (viii) (c) (ix) (a) (x) (b)
(xi) (c) (xii) (b) (xiii) (b) (xiv) (a) (xv) (a) (xvi) (a) (xvii) (d) (xviii) (b) (xix) (a) (xx) (d)
he

Question 2
(i) State whether True or False. [2]
ot

The formal parameters of a function are the arguments used in the function definition.
Ans. True
Br

(ii) What will happen after the below line of code is executed? [2]
float f = Float.parseFloat(“XXX”);
Ans. An exception will be thrown. The string XXX is not in the form of a floating point number, so it will throw
al

an exception while executing.


(iii) Give a single line example of how the Character wrapper class constructor is used. [2]
oy

Ans. Character c = new Character(‘d’);


(iv) Evaluate the following Java line: [2]
“ABC DEF”.trim()
G

Ans. It will be same as the calling string, i.e. “ABC DEF”. The trim() function makes no changes to the calling
string, as there are no leading or trailing whitespaces in the string.
(v) What is the signature of the pow function in Java? [2]
Ans. Its signature is:
static double pow (double a, double b)

Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10 95
(vi) Give the output of the following expressions: [2]
(a) If x = -9.99, calculate Math.abs(x) (b) If x = 9.0, calculate Math.sqrt(x)
Ans. (a) 9.99 (b) 3.0
(vii) Write an expression in Java for: [2]
(a + b)n
3 +b

n
Ans. Math.pow(a + b, n)/(Math.sqrt(3) + b)
(viii) For what value of the second argument of indexOf(String, int) is the method always equivalent to

ha
indexOf(String)? [2]
Ans. For 0 as the second argument. So, indexOf(“abcdef”, 0) is the same as indexOf(“abcdef”), assumingthe calling
object is the same in both the calls.

as
(ix) What value is stored in the variable ln after the code is executed? [2]
String str = “This is a string”;
int ln = str.length();

ak
Ans. ln stores 16.
(x) What is the minimum length of the array y, in order to not get an exception during the execution of the below
code? [2]
for(int i =0;i < x.length;i++)

Pr
{
y[i*i] = x[i];
}
You may assume that x.length is 8.
rs
Ans. 50.
The highest value that i acquires is 7, or x.length – 1. So, highest index of y is 49 (i.e. 7 x 7). So, the size
of y must be 50 or more.
he

SECTION B
ot

(Answer any four questions from this Section)


The answers in the section should consist of the programs in either BlueJ environment or any
Br

program environment with java as the base.


Each program should be written using variable description/memonic codes so that logic of the
program is clearly depicted.
Flowcharts and algorithms are not required.
al

Question 3 [15]
oy

Take as input integers till a 0 (Zero) is entered. After that, find out the Arithmetic mean and Geometric mean
of these numbers (except the zero). For example:
2 3 6 12 8 6 0
G

AM: 6.16
GM: 5.24
Ans. import java.util.Scanner;
/**
* Write a description of class AMGM here.

96 Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10
*
* @author (your name)
* @version (a version number or a date)
*/
public class AMGM
{
// instance variables - replace the example below with your own
private int x;

n
public static void main(String[] args)
{

ha
int[] narr = new int[25];
Scanner sc = new Scanner(System.in);
int num, i = 0;
num = sc.nextInt();

as
do {
narr[i++] = num;
num = sc.nextInt();
}while (num != 0);

ak
//Calculating sum
int sum = 0;
for(int j = 0;j < i; j ++)
{

Pr
sum += narr[j];
}
System.out.println(“AM is “+sum/(float)i);
//Calculating product
rs
int prod = 1;
for(int j = 0; j < i ; j ++)
{
he

prod *= narr[j];
}
System.out.println(“GM is “+Math.pow(prod, 1/(float)i));
}
ot

Question 4 [15]
Br

Take as input an integer n and take n strings as input. Print out all pairs of strings such that the first string is
wholly contained within the second string.
For example:
al

able capable dive nosedive divergent


(able, capable) (dive, nosedive) (dive, divergent)
Ans. import java.io.*;
oy

/**
* Write a description of class whollyContained here.
*
G

* @author (your name)


* @version (a version number or a date)
*/
public class whollyContained
{
// instance variables - replace the example below with your own

Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10 97
private String[] starr;
int sz;

/**
* Constructor for objects of class whollyContained
*/
public whollyContained()
{

n
// initialise instance variables
try {

ha
BufferedReader bf = new BufferedReader(new InputStreamReader
(System.in));
sz = Integer.parseInt(bf.readLine());
starr = new String[sz];

as
System.out.println(“Enter the “+sz + “ strings.”);
for(int i = 0;i < sz;i ++)
{
starr[i] = bf.readLine();

ak
}
}
catch(IOException ie)
{}

Pr
catch(NumberFormatException nfe)
{}
}
rs
/**
* An example of a method - replace this comment with your own
*
he

* @param y a sample parameter for a method


* @return the sum of x and y
*/
public void checkForPattern()
{
ot

for(int i = 0;i < sz;i ++)


{
for(int j = 0;j < sz; j++)
Br

{
if (i == j || starr[i].length() >= starr[j].length())
{
continue;
al

}
else {
for(int m = 0;m < starr[j].length()-1; m++)
oy

{
for(int n = m+1; n<= starr[j].length();n++)
{
G

if(starr[i].equals(starr[j].substring
(m, n)) == true)
{
System.out.println(starr[i] + “
and “ + starr[j] + “ have
such a relationship.”);

98 Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10
}
}
}
}
}
}
}
public static void main(String[] args)

n
{
whollyContained wc = new whollyContained();

ha
wc.checkForPattern();
}
}

as
Question 5 [15]
Write a program in Java to generate all the alternate letters in the range of letters from A to Z.
Ans. public class AlternateLetters

ak
{
public static void main(String args[]) {
for (char ch = ‘A’; ch <= ‘Z’; ch = (char)(ch + 2)) {

Pr
System.out.println(ch);
}
}
}
rs
Question 6 [15]
A string is called namic string when it contains an equal number of upper and lower case alphabets. It may
he

contain other characters and that does not make any difference. Design a class that takes as input a string and
outputs whether the string is namic or not. For example:
abcDEF (Is Namic)
ot

erwer (Not namic)


lKoPWEsd (is namic)
Ans. import java.io.*;
Br

/**
* Write a description of class NamicOrNot here.
*
* @author (your name)
al

* @version (a version number or a date)


*/
public class NamicOrNot
oy

{
// instance variables - replace the example below with your own
private String x;
G

int uppercnt, lowercnt;

/**
* Constructor for objects of class NamicOrNot
*/
public NamicOrNot()

Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10 99
{
// initialise instance variables
uppercnt = lowercnt = 0;
x = “”;
try
{
BufferedReader bf = new BufferedReader(new InputStreamReader
(System.in));

n
x = bf.readLine();
}

ha
catch (IOException ie)
{}
catch (NumberFormatException nfe)
{}

as
}

/**

ak
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y

Pr
*/
public void countLowerUpper()
{
// put your code here
rs
for (int i = 0;i < x.length(); i ++)
{
if (x.charAt(i) >= ‘a’ && x.charAt(i) <= ‘z’)
he

{
lowercnt++;
}
else {
ot

if (x.charAt(i) >= ‘A’ && x.charAt(i) <= ‘Z’)


{
uppercnt++;
Br

}
}
}
}
al

public void assess()


{
if (lowercnt == uppercnt)
oy

{
System.out.println(“Is a Namic string”);
}
G

else {
System.out.println(“Is NOT a Namic string”);
}
}
public static void main(String[] args)
{

100 Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10
NamicOrNot non = new NamicOrNot();
non.countLowerUpper();
non.assess();
}
}

Question 7 [15]

n
Create a class to take as input 10 numbers into an array. Scan through the array to find the number of positives,
negatives and zeroes from among the entered numbers.

ha
Ans. import java.io.*;
/**
* Write a description of class posNegZeroes here.

as
*
* @author (your name)
* @version (a version number or a date)

ak
*/
public class posNegZeroes
{
// instance variables - replace the example below with your own

Pr
private int[] x;
int sz;
int pos, neg, zeroes;
rs
/**
* Constructor for objects of class posNegZeroes
*/
he

public posNegZeroes()
{
// initialise instance variables
ot

sz = 10;
pos = neg = zeroes = 0;
try {
Br

x = new int[sz];
BufferedReader bf = new BufferedReader (new InputStreamReader
(System.in));
System.out.println(“Enter 10 integers.”);
al

for(int i = 0;i < sz; i ++)


{
x[i] = Integer.parseInt(bf.readLine());
oy

}
}
catch(IOException ie)
{}
G

catch(NumberFormatException nfe)
{}
}

/**

Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10 101
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public void countAll()
{
// put your code here

n
for(int i = 0 ; i < sz; i ++)
{

ha
if (x[i] > 0){
pos++;
}
else {

as
if (x[i] < 0)
{
neg++;

ak
}
else {
if (x[i] == 0)
{

Pr
zeroes++;
}
}
}
rs
}
}
public void displayCnt()
he

{
System.out.println(“Number of positive integers =”+pos);
System.out.println(“Number of negative integers =”+neg);
System.out.println(“Number of zeroes =”+zeroes);
ot

}
public static void main(String[] args)
Br

{
posNegZeroes pnz = new posNegZeroes();
pnz.countAll();
pnz.displayCnt();
}
al

}
oy

Question 8 [15]
Write a generalised program to take a proverbial statement (like “Failures are the pillars of success”) as an
input from the user and then output the frequency of the vowels occurring in the statement.
Ans. import java.io.*;
G

public class FreqVowel


{
public static void main(String a[])throws IOException
{
BufferedReader br =

102 Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10
new BufferedReader(new InputStreamReader(System.in));
String str=new String();
System.out.println(“Enter new String”);
int n[] = new int[5];
for(int i=0; i<5; i++)
n[i] = 0;
int number = 0;
str = br.readLine();

n
int s = str.length();
System.out.println(s);

ha
for(int i=0; i<s; i++)
{
if(str.charAt(i) == ‘a’)

as
n[0]++;
else if(str.charAt(i) == ‘e’)
n[1]++;
else if(str.charAt(i) == ‘i’)

ak
n[2]++;
else if(str.charAt(i) == ‘o’)
n[3]++;

Pr
else if(str.charAt(i) == ‘u’)
n[4]++;
}
number = n[0] + n[1] + n[2] + n[3] + n[4];
rs
System.out.println(“No of a” + n[0]);
System.out.println(“No of e” + n[1]);
System.out.println(“No of i” + n[2]);
he

System.out.println(“No of o” + n[3]);
System.out.println(“No of u” + n[4]);
System.out.println(“No of vowels” + number);
}
ot

}
Br
al
oy
G

Goyal’s ICSE Computer Applications Specimen Question Paper with MTP Class 10 103

You might also like