You are on page 1of 4

Model Test Paper 12 (Unsolved)

Maximum Marks: 100


Time allowed: Two hours
Auswers to this Paper must be written on the pajper provided separately.
You will not he 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 itended marks for questions or parts of questions are given in brackets 1 ).

SECTION A

(Attempt all questions from this Section)


Question 1 201
Choose the correct answers and write the correct option.

(i) The parent class also is known as the


(a) Base class (b) Super class

(c) Either (a) or (b) (d) None of these

(ii) How many elements does the following aray contains?


int[l data= {1,2, 3, 4)
(a) 3 (b) 4 (c) 5 (d) 6

(iii) Math.pow (3, 2) + Math.ceil (4.2)

(a) 15.0 (b) 14.0 (c) 13.0 (d) 12.0

(iv) Predict the output of the following


Math.round (16.7) +Math.floor (7.1)

(a) 20.0 (b) 24.0 (c) 25.0 (d) 21.0

(v) variables are the variables that contain the state of an object.
(a) Class (b) Object (c) Instance (d) Hybrid
(vi) The modifier states that the method is accessible to other classes.

(a) Static (b) Main (c) Void (d) Public

(vii) Primitives that are fields in a class are automatically initialized to:

(a) Zero (b) One (c) Two (d) Three


(vii) There are two varieties of methods defined in a class. They are instance methods and:
(a) Program methods (b) Skipper methods
(c) Runner methods (d) Class methods
97
(Ix) What is the purpose of the below function'

Character. isWhiteSpace () input 1S a whitespace


whether the
Checks
(a) Checks whether the input is a space (b)
Nonc of these
(c) Checks whether the input is empty (d)

(1) Write the output of the following program snippet.


Char A

1nt (int) ct 32:

yst em.out.println ( (char) n) ; (d) None of these


(a)13 (b) C" (c) a
(i) What do you mean by abstraction? functions
the use of
(a) Minimising the use of variables (b) Minimising
details
background and
without including
d c t or
representing essential features
(d) None of these
call s.length). where s is a variable of String ype
N
what is
basically returned by the
character of the string
(a) First character of the string (b) Last
in the string
(c) Length of the string (d) Trailing blanks
1s from:
When accessing expressions that have multiple dot operators used, the associativity
n
(a) Left to right
(b) right to left
(c) There is no such thing
(d) It is not allowed to use multiple dots in an expression
(xiv) Which type of variables are available to the scope of the method in which it is declared only?

(a) Local variables (b) Formal variables

(c) Instance variables (d) None of these

(xv) Which keyword is used to include the classes of the package in the program?
(a) Export b) Import (c) Include (d) Exclude

(xvi) Which of the following are the fields of the class whose values are the same in all instances of the class?
(a) Static (b) Private (c) Protected (d) Final
(xvii) Name the class which is the superclass for all the classes in Java.
(a) Class itself (6) Object class
(c) Library (d) Package
(xvii) What are the values stored in variables rl and r2?
double rl = M a t h . a b s (Math.min ( - 2.83, -5.83))

double r2 = Math.sqrt (Math. f l o o r ( 1 6 . 3 ) ) ;

(a) rl= 5.83, r2=4.0 (b) rl= 2.83, 12=4.0 (c) rl= 5.83, r2=3.0 (d) rl= 3.83, r2=6.0
(xix) Which of the following is/are primitive data type?
(a) boolean (b) char (c) Both (a) and (b) (d) None of these
(xx) Which of the following isare the correct way of declaring an array?
(a) String[] difficult Words; (b) int temps[ ]:
(c) both (a) and (b) (d) none of these
Question 2
be used and to test for digit, isDigit() can be used. Is
() To find whether the character is a letter, isLetter() can
there any function that combines these two functions, i.e.
checks whether the character is a letter or a digit? [2
of the its the below linc will always return what value? 12
(ii) Irrespective alphabet or case,

isLowerCase (ch) 1 isUpperCase (ch)


You may assume that the character ch is some English alphabet.

(ii) Describe the default access specifier.


121
Describe the specifier.
21
(iv) private access

of the class is Crane, then the name of the constructor will be 21


(v) If the name

What does a constructor return?


2
(vi)
object of this type ina
If the below line is correct, then of what class type is
a? How can you initialize an
(vii) 2
Java code?

a.intValue ();
the
method definition before you. How will you deduce
the last statement executed in
(vii) Suppose you have a
2
method?

same word.
21
(ix) Fill in the blank in the two sentences below with the
method belongs to the class rather than object
of a class.
A
creating instance ofa class.
be invoked without the need for
an
A method can

data types.
121
Give the names for the wrapper classes of these primitive
(x) (d) short
(c) double
(a) boolean (b) char

SECTIONB

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

15
Question 3 for some integer n. For example:
is number that can be written in the form of n.(nt1)/2,
A triangular number
a

3.4/2 6.
6 is a triangular number, as smaller than this
m, and prints out all positive integral integers
class that takes as input an integer
Define a

number that are triangular.

For example:
10 (as input)
are all triangular and smaller.
1, 3,
|15
Question4 which contain an integer in it. For example:
5 strings. Print out the strings
Take as input
Devendra 99
Kapugedara
Smit23h
Ten1Odulkar
Vir18T
Smit23h the outputsS)
Ten1Odulkar Vir18T (This line are

Question 5 15
to input set of 20 letters, Convert each letter into upper
case. Fina and display the numher
er
CProgram a

of vowels and number of consonants present in the set of given letters


Question 6 1
Detine a class to declare an array of size 20 of double datatype, accept the elements into tne aray and perfonm

the following:

Calculate and print the sum of all the elements.


Calculate and print the highest value of the array.

Question 7 [15
Write a program to bubble sort the following set of values in ascending order:

5, 3, 8, 4, 9, 2, 1, 12, 98, 16

Question 8 [15
Overload the print) function so that:
Write a program in Java to accept a name containing three words and display the surname first, followed by
the first and middle names.

Sample Input: MOHANDAS KARAMCHAND GANDHI

Sample Output: GANDHI MOHANDAS KARAMCHAND

You might also like