Mock Paper

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

MOCK PAPER-1

ACHIVERS COACHING CLASSES

CREATED BY-CHAITANYA SRIVASTAV

DIFFICULTY LEVEL- HARD

M.M-100 M.T-2hrs

NOTE:- NO EXCUSE OF QUESTIONS BEING OUT OF SYLLABUS OR BEING NOT TAUGHT


WILL BE ENTERTAINED AT ANY COST. THE QUESTION PAPER HAS BEEN MADE EXACTLY IN
ACCORDANDE WITH THE LATEST SYLLABUS AND THE LATEST PATTERN PUBLISHED BY
THE COUNCIL.MULTIPLE VERIFIED SOURCES WERE USED WHILE MAKING THIS QUESTION
PAPER.

MULTIPLE CHOICE QUESTIONS [1*20=20]

1. int marks[ ]= new int[ 10]


in the above array name it’s base type:
(a) int (b)10 (c)new (d)marks
2. in the below code snippet find the number of errors:

int marks[ ]= new int[ 10];

for(int i=0; i<10; i++)

{
marks[i]= i;
}
(a)3 (b)1 (c)0 (d)can’t say

3. the array int x[10] occupies;

(a)10bytes (b)40bytes (c)20bytes (d)80bytes

4. give the output of the following string methods


“MISSISSIPPI”.indexOf(‘S’)+ “MISSISSIPPI”.lastIndexOf(‘I’)
(a)10 (b)12 (c)22 (d)11

5. each primitive data type belongs to a specific:

(a)block (b)object (c)Wrapper class (d)none of the above

6. between binary search and linear search which is faster for a


random element:

(a)binary search (b)equal (c)linear search (d)none

7.What is the name given to parameters in a subroutine definition:

(a)formal parameter (b)dummy parameter (c)both a and b (d) none

8. what is the significance of * while importing a package

(a)it lets you specify that there are0 or 1 character only

(b)it lets you specify that the * may be replaced by any string

(c)it is the literal * character itself

(d)none of the above

9. what keywords can be found in a java class exhibiting inheritance

(a)intends (b)derives (c)delivers (d)extends

10. choose the odd one out:

(a)default constructor (b)copy constructor

(c)parameterised constructor (d)constructor overloading

11.based on following code snippet , conclude on the statement:

Public class StopLight

int RedGreenYellow;

change light(){
RedGreenYellow=++RedGreenYellow%3;

The methods in a class definition are named ,self-contained blocks of


code that typically operate on the fields that appear in the:

(a) object definition (b)interface definition

(c)class definition (d)function definition

13.which function returns a Double object holding the value given by


the specified String?

(a)ToString(double) (b)valueOf(String) (c)parseDouble(String) (d)none

14.In the below code, which is the class under which main method is
called: public class HelloObject

void speak(){

System.out.println(“hello from an object”);

Class HelloTester{

Public static void main(String[]args){

HelloObj ect anobj ect=new HelloObj ect();

anObject.speak();

(a)HelloObject (b)HelloTester (c)both a and b (d)none of the above

15. n=10000;

while(n>100){

n=n/10;}

System.out.println(n);

How many times the loop is executed and what is the output?
(a) Loop is executed 2 times and the output is 100
(b) Loop is executed 3 times and the output is 10
(c) Loop is executed 2 times and the output is 10
(d) Loop is executed 2 times and the output is 1000

16. give the output of the following java statements :

“JAVA.to Lowercase();

(a)Java (b)java (c)erroneous statement (d)JAVA

17. all calls to methods must have __after them, even if that methods
takes no arguments. As in:- myObject.methodNoArgs();

(a)curly braces (b)parenthesis (c)square brackets (d)none

18. for the following function definition, what is the return type that
should be specified ? _______isBlack (Color colour)

if(colour ==black)

return(true);

else

return(false);

(a) int (b)short (c)double (d)Boolean

19. in the below code what are the names of data members of the
class?? class clock

int hours; int minutes;

void readtime(int h, int m)

{
hours = h;

minutes=m;

} }

20. what determines both the visibility and lifetime of the variable
names defined within the scope??

(a)data hiding (b)scope (c)garbage collector (d)encapsulation

QUESTION-2 [2*10=20]
1. FIND THE OUTPUT:-
String st= “MALAYALAM”;
int p= st.indexOf(‘A’,4);
String st1= “COMPUTER”;
int p1= st1.indexOf(‘C’,3);
int sum=p+p1;
System.out.println(sum);
2. Define boxing with an example.
3. Describe the output of:-
“MIDAS”.lastIndexOf(‘ ’);
4. Between the pass by value and pass by reference , what method
will allow lasting changes to the object when passed as arguments
to a method?
5. For the below string how can you find (using a single condition),
whether the last character of the string is a space:-- (‘ ’);
6. Fill in the blanks for the below code:-
Public void update(int x, int y)
{
____________ (1)
____________ (2)
}
The class itself contains two integer members variables, x and y.
Update the x with x and y with y.
7. Evaluate the following java line:- “ATACAMA”.replace(‘A’, ‘B’).concat(“RR”);

8. Rewrite the following program segment using if-else statements instead of the ternary
operator:

c = (x >= 'A' && x<= 'Z') ? "Upper Case Letter" : "Lower Case Letter";
9. State the output when the following program segment is executed:
String a ="Smartphone", b="Graphic Art";
String h=a.substring(2, 5);
String k=b.substring(8).toUpperCase();
System.out.println(h);
System.out.println(k.equalsIgnoreCase(h));
10. Give the output of the following:

1. Math.floor (-4.7)
2. Math.ceil(3.4) + Math.pow(2, 3)

SECTION-B
{answer any four questions from this section}
Question 3

Write a program to use a class Account with the following specifications:


Class name — Account
Data members — int acno, float balance
Member Methods:

1. Account (int a, int b) — to initialize acno = a, balance = b


2. void withdraw(int w) — to maintain the balance with withdrawal (balance - w)
3. void deposit(int d) — to maintain the balance with the deposit (balance + d)

Use another class Calculate which inherits from class Account with the following
specifications:
Data members — int r,t ; float si,amt;
Member Methods:

1. void accept(int x, int y) — to initialize r=x,t=y,amt=0


2. void compute() — to find simple interest and amount
si = (balance * r * t) / 100;
a = a + si;
3. void display() — to print account number, balance, interest and amount

main() function need not to be used

Question 4

An Abundant number is a number for which the sum of its proper factors is greater than the number
itself. Write a program to input a number and check and print whether it is an Abundant number or
not.

Example--- :Consider the number 12.

Factors of 12 = 1, 2, 3, 4, 6 Sum of factors = 1 + 2 + 3 + 4 + 6 = 16

As 16 > 12 so 12 is an Abundant number.

QUESTION-5

Define a class to overload the method print as follows:-

void print () – to print the format:- 13579


1357
135
13
1

void print (int n) – to print the sum of given series:- S = 1! + 2! + 3! + …. + n!

void print(int a, char ch)- if ch=s or S print the square of the number
else if ch=c or C print the cube of the number.

Question 6

Write a program in Java to store 20 temperatures in °F in a Single Dimensional Array


(SDA) and display all the temperatures after converting them into °C.

Question 7

Write a program to accept a list of 20 integers. Sort the first 10 numbers in ascending
order and next the 10 numbers in descending order by using 'Bubble Sort' technique.
Finally, print the complete list of integers
Question 8

Consider the sentence as given below:


Blue bottle is in Blue bag lying on Blue carpet
Write a program to assign the given sentence to a string variable. Replace the
word Blue with Red at all its occurrence. Display the new string as shown below:
Red bottle is in Red bag lying on Red carpet

SPACE FOR ROUGH WORK:-

THE END…..

You might also like