Paper: Model
Paper: Model
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
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.
(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 ;
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.