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

Computer Paper 2

This document provides a model test paper with multiple choice questions about Java programming concepts. It contains: 1) 17 multiple choice questions in Section A testing knowledge of Java strings, data types, object-oriented concepts like inheritance and abstraction, and methods. 2) The test paper is divided into two sections, with Section A containing all the multiple choice questions and Section B containing 4 additional questions. 3) Instructions specify the test allows two hours and marks are provided in brackets for each question or part.

Uploaded by

Mahi Rajne
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)
50 views4 pages

Computer Paper 2

This document provides a model test paper with multiple choice questions about Java programming concepts. It contains: 1) 17 multiple choice questions in Section A testing knowledge of Java strings, data types, object-oriented concepts like inheritance and abstraction, and methods. 2) The test paper is divided into two sections, with Section A containing all the multiple choice questions and Section B containing 4 additional questions. 3) Instructions specify the test allows two hours and marks are provided in brackets for each question or part.

Uploaded by

Mahi Rajne
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 13 (Unsolved)

Maximum Marks: 100


Time allowed: Tiwo hours
Answers to this Pajper must be written the paper provided separately
on

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.


questions from Section B.
Attempt all questions from Section A and any four
The intended marks for questions or parts of questions are given in brackets [ ].

SECTIONA

(Attempt all questions from this Section)


Question 1
[20
Choose the correct answers and write the correct option.

(i) Which of the following term denotes an array of characters?


(b) StringBuffer (c) Index (d) Program
(a) String
(ii) What is the use ofcompareTo(String) method? of the
It compares two string by ignoring the case (b) It compares two strings by taking care case
(a)
(c) It concates two strings (d) None of these

(ii) Which method is used to find the length of the specified string?
(b) length0 (c) long) (d) StrLength)
(a) len)
What the two methods of the String class to search a string?
(iv) are
(b) Indexof() and Lastindexof()
(a) indexOf) and lastlndexOf)
both correct (d) None of these
(c) Either (a) or (b) are

other class, it still extends:


(v) In Java, if your class does not extend any
(6) Java.lang.instance (c) Java.lang.Object (d) Java.lang.nodes
(a) Java.lang.Classes
following code?
(vi) What is the output of the
char ch =
'y'
char chr = Character.toUpperCase (ch) ;

int p (int) chr;


System.out.println (chr+ "IE" + p);

(b) y 121 (c) y 120 (d) Y 65


(a) Y 89

(vii) What is thepurpose of the below function?


Double.toString ()
6) Converts String type to Double wrapper object
Converts a String type to a double
a
(a)
Converts any object to a double
(c) Converts a double data to a String (d)
(viii) Which of the following is NOT a visibility mode used in the class?
(b) protected (c) publie (d) static
(a) private
r ith ATP Class !0
101
ction call?
ca.

below method definition, what is returned to the below


(x)For the
int storage (String s)
return s.length () 2
int add = storage ("Moon "); (d) 7
(a) 10 (b) 9 (c)8
()Which of the below is a correct syntax for writing default constructor int)
(int,
(a) <class name> (int) (b) < c l a s s _ n a m e >

****** ..*

(c) <class_name> () (d) None of these

(xi) Which of the following is NOT a part of the method header?


(c) return statement
(d) Either (b) or (c)
(a) Access specifier (b) Method body
(xii) What happens when the following code is declared?
static int special;
(a) The value of special will keep on changing during the course of the program.
(b) The value of special will remain same for all the instances of the class.
instances of the given class.
(C) If the value of special is changed, then it will be changed in all
(d) Both (b) and (c)
(xii) Consider the following code and answer the questions that follow:
class academic

static int x, y;
void access ()

int a, b
academic student = new a c a d e m i c( ) ;

System.out.println ("Object created");

What is the object name of class academic?


(a) students (b) student (c) Access (d) Object is not declared
(xiv) Choose the odd one out.
(a) public (b) protected c) private (d) package
(xv) Access modifiers are used to regulate
(a) Internal use of classes (b) External use of classes
(c) Both (a) and (b) (d) None of these
(xvi) Which of the following is used to extend the functionality of existing classes by making a subclass and superclass?
(a) Polymorphism (b) Inheritance (c) Abstraction (d) None of these
(xvi) What is the return type of the method 'x.endsWith(String suffix)'?
(a) int (b) String (c) char (d) boolean
(xvii) What would the following code do?
int index = 0;

index = text. indexof( '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
(xix) What would the following code do?
int index 0

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
(xx) How many parameters does the following parameter list contain?
int add (int X, intt y)
(a) One (b) Twob (c) Threee (d) Four

Questionn2

() Fill in the blanks with the same word. 121


functions either change depending on state or have side effects(for instance, displaying something
on screen). function does not return a value.
(i) Fill in the blank: 21
Call by is the default method of passing arguments to a function/method.

(i) Is there any difference between: 2


String str new String () ;
and
String str
(iv) To include the BufferedReader and InputStreamReader objects, what single import statement can
you use? |21
(V) What does the following code do? 2
public class ToStringDemo

publiC static void main (String [j args)

Double d = 858.48

String s =
Double.toString (d) ;

dot = S.indexof ( * . ' ) ;


int
System.out.println (s.length () -dot 1);

2
(vi) What is the difference between:
int i

String sl i
Or
String s2= String.valueOf (i);
121
(vii) What is the use of the java.io class packages?
121
(vii) What is the Object class?
what are the values of x and y? 21
(ix) If int n[] (1,2,3, 5,7,9, 13, 16),
n[2]);
Math.pow (n [4]1,
Math.sqrt (n [5] +n [7])
two lines.
121
the below
(x) Find the value of phrase based on

Too many";
String phraSe
the broth";
phraset=
"
cooks spoil
103
Pucstin Paper with MTP Class 10
SECTION B

(Answer any four questions from this Section)


n e 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 (151
Write a program in Java to enter a String/Sentence and display the longest word and the length of the longest
word present in the String.
Sample Input: "TATA FOOTBALL ACADEMY WILL PLAY AGAINST MOHAN BAGAN
Sample Output: The longest word: FOOTBALL: The length of the word: 8
Questionn 4
Write a program to input a sentence. Convert the sentence into uppercase letters. Display the words along with
[15
frequency of the words which have at least a pair of consecutive letters.
Sample Input: MODEM IS AN ELECTRONIC DEVICE
Sample Output: MODEM DEVICE
Number of words
containing consecutive letters: 2
Question 5
A is
|15
string said be
to check if none of the letters present in the string are repeated. Write
Unique' a program to
accept a string and whether the string is Unique or not. The program displays a message accordingly.
Sample Input: COMPUTER
Sample Output: Unique String
Question 6
Write a program that will read a sequence of
15
positive real numbers entered by the user and will print the same
numbers in sorted order from smallest to largest. The user will
input a zero to mark the end of the input.
Assume that at most 100 positive numbers will be entered.
Question 7
Define class in Java to 151
a
input a sentence and convert it into uppercase and count and
display the total number
of words starting with a letter 'A'.
Class Name: WordsnSentence
Example:
Sample Input: ADVANCEMENT AND APPLICATION OF INFORMATION TECHNOLOGY
ARE EVER CHANGING.
Sample Output: Total number of words starting with letter A' = 4
Question 8
Write a program in Java to accept a String in uppercase and replace all the vowels
[15
Asterisk (") sign. present in the String with
Sample Input: "TATA STEEL IS IN JAMSHEDPUR"
Sample output: T*T* ST**L *S *N J*MSH* DP*R

You might also like