0% found this document useful (0 votes)
53 views4 pages

Paper: Model

This document contains a test paper with multiple choice questions to assess knowledge of Java programming concepts like variables, data types, operators, control structures, arrays, inheritance and encapsulation.

Uploaded by

Soumya Bishnu
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)
53 views4 pages

Paper: Model

This document contains a test paper with multiple choice questions to assess knowledge of Java programming concepts like variables, data types, operators, control structures, arrays, inheritance and encapsulation.

Uploaded by

Soumya Bishnu
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/ 4

Model Test Paper 14 (Unsolved)

Maximum Marks: 100


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

SECTIONNA
(Attempt all questions from this Section)
Question 1 (201
Choose the correct answers and write the correct option.

) variable is visible/usable within the method that it has been declared in.
(a) A class (b) A local (c) A primitive (d) An object
i) What is the output of the following code?
char c = B'
int i 4
System.out.println(c+i);
System.out.println((int)c +i);
(a) 70 (b) 68 (c) 98 (d) 102

70 68 98 102
(iii) What do you mean by encapsulation?
functions in the form of single unit
(a) A method of combining data and its associated
(b) Use of only one function and multiple class variables
(c) Use of only one class variable and multiple methods

(d) None of these

(iv) For the below code, give the output.


="It is need of the hour";
String str
System. out .println ("substring"hour\":" +
str.indexof ("hour") )
(b) 19 (c) 20 (d) 21
(a) 18
the following line in Java?
(v) What is the value returned by
Math.ceil (6.8)
(b) 9.0 (c) 7.0 (d) 9.0
(a) 8.0

(vi) What is being done in the following code snippet?


int Number;
Number =
System. io.read ()
if ((Number % 2) = 0)

105
l , ATp Clac 10
System.out.println (Even")
else

System.out.println (Odd");
(a) Prints whether a number is Positive, Negative or Zero
(b) Prints whether a number is Positive or non-positive
(c) Prints whether a number entered by user is even or odd
(d) None of these
(vii) 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
(vii) Class modificrs are used to specify two aspects of classes
(a) Access and type (b) Modifier and type (c) Access and Modify (d) None of these
(i) The data in an
object are called its fields, and the procedures that operate on the data are called
ts

(a) Methods. Classes (b) Classes, libraries (c) Instance, methods (d) None of these
() Out of the following options. name the reference datatype.
(a) Object (b) Array (c) Float (d) Char
(xi) What happens when the following code is declared?
private int SiZe;
(a) The size variable is accessible to all methods within the current class.
(b) The size variable is not accessible to any other classes.
(c) The size variable is not accessible to the subclasses of the current class.
(d) All of these
(xii) What would the following code do?
index text.lastIndexof ( ' a ' ) ;
(a) Find first index
position containing 'a' (b) Find last index position containing *a'
(c) Find first index
position of any character (d) Find last index position of any character
(xiii) Which of the following statement(s) is/are TRUE?
(a) Inheritance provides programming by extension as
opposed to programming by reinvention.Inheritance
allows explicitly taking advantage of the
commonality of objects when constructing new elasses.
(b) Inheritance is a
relationship between classes where one class is the parent class of another
(derived) class.
(c) Both (a) and (b) (d) None of these
(xiv) Find the output of the following if the values of the variables are x 2, y 3 and 9
= = =
z
x(++y )%oz
(a) 7 (b) 8 (c) 9
(d) 10
(xv) Find the output of the following code:
String[ = SAMSUNG",
NOKIA", SONY'", "MI CROMAX", BLACKBERRY"}
Systen.out.println(x[1])
Syste.Out.rintln (x [ 3]. length )):
(a) NOKIA (b) SONY (c) BLACKBERRY (d) MICROMAXK
8 10
(xvi) What does signifies?
(a) Scope of the instance variable (b) Seope of the class variables
(c) Both (a) and (b) (d) None of these
106
can contain a mix of:
(xvii) An arithmetic expression
(a) Literals
(b) Variables
(d) All of these
(c) Subscripted variables
to a function tor updation, what kind of argument passing is it
(1vii) 1f you pass the objeet as an argument
known as?
(c) Pass by argument (d) None of these
(a) Pass by value (b) Pass by reference
Java, what is it supposed to mean?
(nix) If you find a this() within a method in
is being invoked
(a) The calling object's constructor
(b) The being reterred to
calling object is

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

() method in the following way, but it was giving error. What is the correct
using his toLowerCase
(Ax) Lalit was
method?
way to invoke this
char c = toLowerCase ( 'A');
(b) char c = 'A'>toLowerCase ();
(a) char c A'.toLowerCase ();
(c) char A'toLowerCase () (d) char c =
Character.to LowerCase ( 'A');

Question2
State whether True or False. 21
(i)
The formal parameters of a function are the arguments used in the function definition.

ii) What will happen after the below line of code


is executed? 21
float f = Float .parseFl oat ("XXX")

line example of how the Character wrapper class constructor is used. 21


(ii) Give a single
2
(iv) Evaluate the following Java line:
ABC DEF".trim ()
21
(v) What is the signature of the pow function in Java?
(vi) Give the output of the following expressions: 21
(a) If x = -9.99, calculate Math.abs(x) (b) If x =9.0, calculate Math.sqrt(x)
in Java for: 21
(vii) Write an expression
(a+b
3 +b
For what value of the second argument of lastIndexOf (String, int) is the method always equivalent
(Vii)
to lastIndexof (String)?

(ix) What value is stored in the variable In after the code is executed?
121
String str This is a string";
int ln =str.length ();
m length of the array y, in order to not get an exception during the execution of the belo
(x) What is the minim
code? 12
for (int i =0;i < x. length; itt)

Yli*il x [ i l ;

You may assume that x.length is 8.


107
SECTIONB

(Answer any four questions from this Section)


The answers in the section should consist of the programs in either BlueJ 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.
Question3
[15
Take as input 20 integers and print out the array values after bubble sort has been done. After bubble sort,
search for the number x as entered by the user in the sorted array using binary search.

Question 4
|15
Takeas 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:
able capable dive nosedive divergent
(able, capable) (dive, nosedive) (dive, divergent)
Question 5
[15
Write a program in Java to generate all the altermate letters in the range of letters from A to Z.

Question6
|15
A namic string when it contains an equal number of upper and lower case alphabets. It
string is called may
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)
erwer (Not namic)
IKoPWEsd (is namic)
Question 7
|15
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.

Question 8 115
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.

You might also like