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

Mock 2

Uploaded by

Ritam Saha
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)
34 views4 pages

Mock 2

Uploaded by

Ritam Saha
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

COMPUTER APPICATION

CLASS-X
PRACTICE TEST-II (MCQ BASED)
Marks: 70 Time-90 min
SECTION A
(Attempt all questions)
Question 1.Tick the correct option (20x1=20)

1. . …………………….. Statement provides an easy way to dispatch execution to different parts of your code based on the
value of an expression.
A. if-else B. switch C. if D. while
2. if(a>b)
c=a;
else
c=b;
It can be written as :
A. c=(b>a)?a:b; B. c=(a!=b)?a:b; C. c=(a>b)?b:a; D. None of the above
3. if(a<0)
System.out.println(“a negative number”);
if(a>0)
System.out.println(“a positive number”);
if(a==0)
System.out.println(“the number is zero”);
The above comes under which of the following statements.
A. if statement B. if-else statement C. if else if statement D. nested if statement
4. public class temp
{
public static void main(String args[])
{
int x=1;
if((boolean)x==true)
System.out.println("True.");
else
System.out.println("False.");
}
}
A. True. B. False. C. Error
5. What will be the return value of the following function test?
int test()
{
int a=6, b=7;
int sum=a+b;
int pr=a*b;
return(sum);
return(pr);
}
A. 13 B. 42 C. 13,42 D. 42,13

6. Calling a method is also termed as


A. parameter passing B. invoking a method C. method header D. none of the above

7. Impure method is also known as


A. mutator B. caller method C. operational method D. none of the above

8. Give the output of the following


int a=1;
for( ;true;a++) {
System.out.print(a+”, ”);
if(a>3)
break; }
A. 1,2,3 B. 1,2,3,4 C. 1,2,3,4, D. 1,2,3,

9. The conditional statement, ………………. can only test for equality, whereas ………………. can evaluate any type of
Boolean expression.
A) if, switch B) switch, if C) while, if D) if, while

10. Object is a …….. entity and Class is a …….. entity.


A. normal, normal B. physical, logical C. logical, physical D. normal, logical

11. A …….. class may not have any abstract method.


A. abstract B. static C. final D. public

12. Keyword ………. is always a reference to the object.


A. new B. this C. super D. class

13. What are features of a default constructer?


A. Accepts no arguments B. No statements in its body C. All the above D. None of the above
14. Predict the output:
int m[]={1,4,9,16,25};
int n[]={11};
for(int i=0;i<5;i++)
System.out.print(n[0]+m[i]+" ");
A) 12 15 20 27 36 B)1 4 9 16 25 C )12 11 15 11 20 11

15. How can we invoke the constructer


A. By normal method call B. Via new operator C. Both a & b D. None of the above

16. …….. is passed to a method by use of call by reference.


A. Variables B. Objects C. Methods D. Operators

17. What is byte code in the context of Java?


A) The type of code generated by a Java compiler B) The type of code generated by a Java Virtual Machine
C) It is another name for Java source file D) It is the code written within the instance methods of a class

18. Write the output of the following:


int a[ ] = { 5, 8, 7, 3, 2 };
a[ 1 ] = a[ 3 ];
a[ 2 ] = a[ 4 ];
a[ 3 ] = a[ 1 ] + a[ 2 ];
for ( int i = 0; i < 5; i + + )
System.out.print( a[ i ] + “,” );

A. 5,3,2,5,2 B. 5,5,3,2,1 C. 1,2,3,4,5

19. When the operators are having the same priority, they are evaluated from …………….. …………. in the order they appear in the
expression.
A) right to left B) left to right C) any of the order D) depends on the compiler

20. If a variable is declared FINAL, it must include ……………………. value.


A) integer B) number C) initial D) float

Question 2. What will be the output of the following: (5x2=10)

a) Find the output of the following program segment c) Find the output :
public static void main(String args[]) String str="The green bottle is in the green bag";
{int s=0; String str1="green";
int a[]={2,4,6,8}; System.out.println(str.indexOf(str1));
for(int i=0;i<=1;i++)
{ d) Find the output
s=a[i]+a[3-i]; char ch = 'k';
System.out.println(s); char chr = Character.toUpperCase(ch);
} int p = (int) chr;
System.out.println(chr + "\t" + p);
b) Find the output of the following program segment
public static void main(String s[]) e)String x="BLUE";
{ char c; String p=" "; int i;
int a,b=0; for(i=0;i<x.length();i++)
int c[]={12,13,14,15,16,17}; {
for(a=0;a<6;a++) c=x.charAt(i);
{ p=c+p;
if(a%2==0) System.out.println(p);
b+=c[a]; }
}
System.out.print(b) }

SECTION B
(Attempt any Four questions.) (10X4=40)
Question 3
Given below is a class with the following specifications
Class Name: Equivalent
Data members: int n – to store first number
int m – to store the second number
Member methods:
a)A parameterised constructor to initialise values to member variables.
b)int sumFactor(int num)- to return factors sum excluding number as its factor.
c)check()- A function to check whether number is an equivalent number or not.
Equivalent numbers are numbers where the factors sum(other than the number itself) are identical.
Ex 159 and 559 are equivalent numbers since their factors sum is same.
159=1,3 and 53= 1+3+53=57
559=1,13 and 43=1+13+43=57
Question 4
Write a program by using a class with the following specifications:
Class name — Salary
Data members — int basic
Member functions:
void input() — to input basic pay
void display() — to find and print the following:
da = 30% of basic
hra = 10% of basic
gross = basic + da + hra
Use a main function to create an object and call member methods of the class.
Question 5:
Using the switch statement, write a menu driven program for the following:
(i) To print the Floyd’s triangle [Given below] (ii) To display the following pattern:
1 I
23 IC
456 ICS
7 8 9 10 ICSE
11 12 13 14 15
For an incorrect option, an appropriate error message should be displayed.
Question 6
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
Question 7
Write a program to input a binary number(base 2) and convert to its decimal equivalent(base 10)
SAMPLE INPUT : (110011)2
SAMPLE OUTPUT: (51)10
Question 8
Design a class to overload a function sum() as follows:
(i) int sum(int a, int b) to calculate and return the sum of all the even
numbers in the range a to b.
Sample Input:
a = 10
b = 20
Sample Output:
Sum = 90
(ii) double sum(double n) to calculate and return the product of the following series:
Product = 1.0 × 1.2 × 1.4 × … × N
(iii) int sum(int n) to calculate and return the sum of only odd
digits of the number N.
Sample Input: N = 43961
Sample Output: Sum = 13
Write the main() method to create an object and invoke the above methods.

You might also like