0% found this document useful (0 votes)
20 views

XPaper02

Uploaded by

avnibhatt006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

XPaper02

Uploaded by

avnibhatt006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Model Test Paper 6 (lJnsolved)

Maximum Marks: JOO


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.


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 [}.

---------.. .«: SECTION A )


(Attempt all questions from this Section)
Question 1 [20]
Choose the correct answers and write the correct option.
(i) From the given array Y [ J [ J = { { 3 , 4, 5 }, {6 , 7, 8 } , { 1, 2, 3 } };
The element at Y [ 2 J [ 2 J 1s:
(a) 1 (b) 2 (c) 3 (d) 4
(ii) Decide how many searches using linear search it will require to successfully search for 2 from the below array?
15 12 2 3 4 5
(a) 2 (b) 3 (c) 4 (d) 5
(iii) Packages in Java are:
(a) A special class (b) Groups of classes
(c) A special canst variable (d) None of these
(iv) Which function from String library removes the leading and trailing whitespace from the string? .,
(a) proper (b) prim (c) trim (d) remove
(v) All calls to methods must have _ _ after them, even if that method takes no arguments.
As in:
myObj ec t.methodNoArg s ();
(a) Curly braces (b) Parentheses
(c) Square brackets (d) None of these
(vi) What keyword can be found in a Java class exhibiting inheritance?
(a) intends (b) derives (c) delivers (d) extends
(vii) In the below code snippet, what is the return type of the method?
int storage (String s) {
r e turn s. l ength () * 2; }
(a) int (b) Boolean (c) return (d) string
70 Goyal 's !CSE Computer Applications Specimen Question Paper with MTP Class JO
(xv) What is the other name of encapsulation?
(a) Information hiding (b) Information processing
(c) Information storing (d) Information reusing
(xvi) MethQd calls to objects use:
(a) Arrow notation (b) Caret notation
· (c) Dot notation (d) None of these
(xvii) What is the name given for:
"Sometimes there are two or more possible matches for an invocation of a method . due to similar method
signature, so the compiler cannot determine the most specific match."
(a) Multiple inheritance (b) Deep inheritance
(c) Multiple invocation (d) Ambiguous invocation
(xviii) The constructors in a class all have the same name, but their signatures are differentiated by their:
(a) Return types (b) Use of overloaded keyword
(c) Parameter lists (d) None of these
(xix) Write a set of statements that would find and print the size of array ar[] = {2, 5, 6, 7, 8, 9, 10};
(a) int len = ar.length;
System.out.println("The size of array="+len);
(b) int len = ar.length();
System.out.println("The size of array="+len);
(c) int len = ar.len;
System.out.println("The size of array="+len);
(d) None of these
(xx) Differentiate between parseint() and toString().
(a) parselnt separates out the integer based on comma and toString joins the strings
(b) parselnt returns subparts of the integer and toString converts integers to strings
(c) parseint returns the string converted into an integer and toString converts any object to string
(d) None of these

Question 2
(i) Evaluate the below Java line: [2]
System.out.println(isUpperCase('Z'));
(ii) Fill in the blanks for the below code to change the array into an array that contains double the parent array. [2]
int[] x = (4, 2, 6, 12, 15, 10, 8};
for(int i = 0; i<x.length;i++)

(l) _ _ _ __

Print((2) );

(iii) The below code snippet checks whether or not any character other than letter or digit is contained in the string
str. Fill in the blanks of the code in order to get the code correct. [2]
boolean ( 1) _ _ _ __
for(int i = 0; i< str.length;i++)

72 Goyal s !CSE Computer Applications Specimen Question Paper with MTP Class 10
(viii) What does the below routine return?
Random rand = new Random ()
· (a) It returns random decimal numbers. (b) It returns random strings.
(c) It returns random integers. (d) It returns a null string only.
(ix) Name which block precedes the block as visible below.
catch ( IOException e)

System. out. println ("Er r or reading from user") ;


)

(a) try block (b) Another catch block


(c) Either (a) or (b) (d) Any code
(x) The garbage collector feature in Java is used to avoid :
(a) Memory leak (b) Memory management
(c) Memory arrangement (d) Memory scope
(xi) In the class statement, "public static void main (String args[])" the keyword public stands for _ _ _ _ __
(a) The method is unchanging and implicitly final
(b) The method does not return a value
(c) The method is accessible to other classes.
(d) None of these
(xii) The statement to invoke the default constructor of a class "State" is - - - - -- - -
(a) State obj= new state ; (b) State obj = State();
(c) State obj= new State(); (d) State obj= new State()
(xiii) Keywords are always in:
(a) Uppercase (b) Sentence case (c) Lowercase (d) Toggle case
(xiv) View the following code and answer the question.
public void TestSample(int var)

switch(var)

case 1:
System.out.println("good 11
);

break;
case 2:
System.out.println("better");
break;
case 3:
System.out.println("best");
break;
default:
System.out.println("invalid");
break;

If value 4 is passed to the function the output will be:


(a) best (b) invalid (c) good (d) better
Goyal s !CSE Computer Applications Specimen Question Paper with MTP Class 10 71
if(isLetterOrDigit(str.charAt(i)) false)

System . out .println(( 2)~~~~~

(3) _ _ __ _

break;

if (flag false)

System.out .pri ntln("String is alphanumeric");

(iv) How would you take the input of a single character from the keyboard in a Java program? [2]
(v) Give any one advantage of using reference type of variables. [2]
(vi) How does the compareToI_gnoreCase (String) method work? [2]
(vii) Evaluate the following Java line: [2]
"Hello".endsWith("lo") && "Conrad".startsWith("con");
(viii) Suppose that you construct a function matchesQ so that it returns true whenever the two strings have some
matching prefix and suffix (of length at least 2) respectively. For the below call of the function, what should
this (assumed) correctly written function ·return? [2]
"abcdef' .matches("retef ');
(ix) Which operator in Java can do the same work as concat(String) of the String class? [2]
(x) Can a class have more than one constructor specified for itself? [2]

----------t~ SECTION B )

(Answer any four questions from this Section)


The answers in the section should consist of the programs in either Bluel environment or any
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.

Question 3 [15]
Define a class to find the sum of first 75 natural numbers.

Question 4 [15]
Define ·a class to accept a number and check whether it is both divisible by 11 and contains at least a substring
which is also divisible by 11. For example:
99 is divisible by 11 but does not contain a number divisible by 11.
1331 is divisible by 11 and contains 33 that is also divisible by 11.
121 is divisible by 11 but does not contain a substring divisible by 11.
Goyal s !CSE Computer Applications Specimen Question Paper with MTP Class I 0 73
Question 5 (15]
Define a class that accepts a number and outputs the value of n, such that:
a. When the number is even, find n such that 2°.x is the number
b. When the number is odd, find n such that 2°.x + 1 is the number.

Question 6 (15]
Define a class that takes as input an integer n and takes n strings as inputs. Print out all pairs of strings such
that the first string has a suffix which is a prefix of the second string. For example:
dam amicable blessed educated gambler
(darn, amicable) (amicable, blessed), (amicable, educated), (blessed, educated) are such pairs.

Question 7 (15]
Define a class with the following specifications:
Class name: student
Member variables: mo - Roll number
Snarne - Student name
Class - The grade he/she studies in
Prefinal, final - The pre-final and final marks obtained
[Declare the variables using appropriate data types)
Member methods :
void accept() -- accept the details from standard input
void process() -- To decide the students who got more in final than the pre-final.
void print() to print the details as per the following format
Rno sname class pre-final final
void main() -- to create an object of the class and invoke the methods.

Question 8 (15]
Design a class that takes as input an integer n from the user. Take n inputs from the user. Print out the digit
that occurs most frequently in the entire set of numbers entered. For example: for 7 numbers,
12 21 34 46 62 29 98
2 occurs most frequently.

. ~
To get the solution of this Model Test Paper Scan this QR Code
•(!)
CODE-slpL
.

74 Goyal s !CSE Computer Applications Specimen Question Paper with MTP Class 10

You might also like