0% found this document useful (0 votes)
2 views12 pages

MCQ Test Computer

Uploaded by

Ujwala Pawar
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)
2 views12 pages

MCQ Test Computer

Uploaded by

Ujwala Pawar
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

MCQ Test

Series
Academic Session 2024-2025
Grade X Computer Application
Marks: 100 Time: 2 Hour
____________________________________________________________________
Q1. Select the appropriate option from the multiple choice given: [50]

1. The ability of a class to provide different implementations of a methods, depending on the


type of arguments that is passed to the method.
a) Encapsulation c) Abstraction
b) Inheritance d) Polymorphism

2. In object-oriented programming, the stress is given on:


a) Procedure c) class
b) Methods d) data

3. The process of combining data and functions that enable together as a single entity is
called
a) Inheritance c) classification
b) Encapsulation d) attributes

4 . Predict the output-


int x =20, y = 10, z=40;
z = ++x * (y--) - y ;
System. [Link](z);
a) 210 c) 201
b) 200 d) 241

5. Derived class inherits from which class.


a) child c) sub
b) static d) base

6. What will be the output of the following loop ?


do{
[Link]("Ashokites");
[Link](" ");
}while(true);
a) Compilation Error c) Ashokites infinite times
b) Ashokites two times d) Ashokites one time

7. How many times will the outer loop execute?


for (int i = 1; i <= 5; ++i)
{
for(int j= l;j<=2;++j)
{
if(i==3)
break;
[Link](j);
}}

a) 2 times b) 5 times

2024-25/Grade X/ Computer Application Page 1 of 12


c) 10 times d) 3 times

8. Which of the following for loop will not be an infinite loop?


a) for(; ;) c) for(a = 0; a < 1; a-- )
b) for(a = -1; a < 1; a++) d) for(a=0; ;a++)

9. Consider the following snippet:


float f = 19.9f;
int i = (int)f;
[Link](i);
a) 19 c) 19.9
b) 19.0 d) 20

10. Which of the following is not a relational operator in Java?


a) >= c) <=
b) != d) =

11. Which is the primitive data type that is 8 byte and is used when you need a range of value wider
than those provided by int?
a) int c) long
b) short d) byte

12. A primitive data type in Java used to store only two possible values, either true or false.
a) boolean c) int
b) Boolean d) float

13. Which of the following is not a keyword?


a) null c) protected
b) extends d) public

14. Identify the type of literals for ‘7’?


a) Real c) String
b) Character d) Integer

15. What is the correct way to declare a constant in Java?


a) constant int PI = 3.14; c) const PI = 3.14;
b) final double PI = 3.14; d) double PI = 3.14;

16. Find the output for the following: [Link](34,([Link](-33));


a) 34.0 c) 33.0
b) 34 d) 33

17. [Link]([Link](5.9)+Math,floor(4.6)); will give which of the following output:


a) 10 c) 9.0
b) 9 d) 10.0

18. The keyword specifics some code to run if there is no matching case in the switch.
a) break c) case
b) default d) switch

19. Which is odd in given options


a) Package c) block

2024-25/Grade X/ Computer Application Page 2 of 12


b) Function d) method

20. _______ variable can be accessed by calling with the class name.
a) Instance c) . Local
b) Class d) Formal

21. Which of the following statements is the most appropriate for the private members?
a). They are visible out of the class in which they are defined.
b) They can be used in the sub-classes.
c) They are only visible in the class in which they are declared.
d) They can be used in same package .

22. Identify the infinite loop:


a) for (int i = 0; i < 10; i++);
b) while (true) {}
c) do { } while (false);
d) for (int i = 1; i < 10; i *= 2) {}

23. What will be he final value of i:


int i = 0;
do {
[Link] (i+” “);
} while (i ++ < 3);

a) 3 c) 4
b) 0 1 2 3 4 d) 0 1 2 3

24. What will be the output of the following snippet:


int i = 5;
while (i --> 0);
{
[Link](i);
}
a) 43210 c) 0
b) 4321 d) -1

25. What will be the result of the following code:


int i = 1;
while (i < 3) {
if (i == 1)
continue;
[Link](i);
i++;
}
a) 0 c) Syntax Error
b) 0 1 2 d) Infinite loop

26. Predict the output for the following:


int x = 3;
switch (x) {
case 1:
[Link]("One");
case 3:
2024-25/Grade X/ Computer Application Page 3 of 12
[Link]("Three");
default:
[Link]("Default");}
a) Three c) Default
b) Three d) Syntax Error
Default

27. A student management program uses the following snippet to categorize students based on
grades:
int grade = 85;
switch (grade / 10) {
case 10:
case 9:
[Link]("Excellent");
break;
case 8:
[Link]("Very Good");
break;
case 7:
[Link]("Good");
break;
default:
[Link]("Needs Improvement");
}
What is the output if grade = 72?
a) Excellent c) Good
b) Very Good d) Needs Improvement

28. What is a "nested if" in Java?


a) An if block containing another if block inside
b) An if condition enclosed in parentheses
c) An if block with a break statement
d) An if block with else if statement

29. What happens if the condition in an if statement is false and there is no else block?
a) Program terminates
b) Code inside the if block is skipped
c) Compilation error
d) Runtime exception occurs

30. You are developing a program where the user can input 1 for "Start", 2 for "Stop", or 3 for
"Pause". If they enter anything else, display "Invalid Input". Which will be the most
appropriate construct that you can use?
a) if else c) switch case
b) nested if d) while loop

31. Read the following snippet


int i = 1;
while (i < 10) {
if (i == 5) {
break;
}
i++;
}
2024-25/Grade X/ Computer Application Page 4 of 12
How many iterations are performed, and what is the value of i when the loop terminates?
a) 5 iterations ,i=5 c) 4 iterations i=5
b) 5 iterations , i=4 d) 4 iterations,i=4

32. A user needs to calculate income tax based on income slabs using conditions. Suggest which construct
is better:
i) ladder if-else
ii) switch-case
iii) if else

a) only i) c) i) , ii) and iii)


b) i) and ii) d) i) and iii)

33._____ function returns the magnitude of a number without any sign


a) [Link]() c) [Link]()
b) [Link]() d) [Link]()

34. What will be the output of [Link](-4);


a) -2 c) Syntax error
b) -2.0 d) Runtime error

35. What is output of [Link](-51.51);


a) -51 c) -52
b) -51.0 d) -52.0

36. What is output of Math. ceil (-0.9);


a) -1.0 c) 1.0
b) 0.0 d) -0.0

37. Which of the following demonstrates method overloading?


i) Two methods with the same name and same parameter list.
ii) Two methods with the same name but different parameter lists.
iii) Two methods with same names , same parameter list and different return type.

a) only i) c) both i) and ii)


b) only ii) d) only iii)

For the question 38 to 40 of Assertion and Reason select the appropriate option from the following:
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct
explanation of Assertion(A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true

38. Assertion(A): An instance variable can be accessed by all instances of a class.


Reason (R): Instance variables are unique to each object and has separate memory for each instance.

39. Assertion (A): A for loop is preferred when the number of iterations is fixed.
Reason (R): The initialization, condition, and update are part of the for loop syntax, making it compact
for fixed iterations.

40. Assertion(A): Java is platform independent.


Reason(R): Byte-code runs on the Java Virtual Machine (JVM), which is usually
2024-25/Grade X/ Computer Application Page 5 of 12
a OS-based interpreter.

41. String word1 = "Hello";


String word2 = word1;
word1 = [Link](1, 2);
[Link](word2+word1);
a) Helloe c) word1
b) e Hello d) HelloHello

42. [Link]("hello".substring(5));
a) o c) Runtime error
b) Syntax error d) space

43. String str=” Trance-Tech”


[Link]([Link](“TranKe”);
a) 24 c) -8
b) 8 d)-24

44. What will be the output of the following:


char arr1[]={'a','b','c','d'};
int x=2;
[Link](++arr1[--x]);
[Link](arr1[x]+3);
a) 99 c) c
102 f
b) c d) 99
102 f

45. Identify the output:


String arr1[]={“WE”,”Rule”,”Trance”,”Tech”,”Computer”};
[Link](arr1[[Link]].length( ));
a) 8 c) Logical Error
b) 5 d) Runtime Error

46. find the output for the following snippet:


String[][] words = { {"Java", "Python", "C++"}, {"HTML", "CSS", "JavaScript"} };
[Link](words[1][[Link]].substring(4).toLowerCase());
a) ascript c) error
b) script d) css

47. What is the process of converting a primitive type into its corresponding wrapper class called?
a) Parsing c) Autoboxing
b) Unboxing d) Wrapping

For 48th to 50th question of Assertion and Reason, select the appropriate option from the below:
(a) Both A and R are true, and R is the correct explanation of the A.
(b) Both A and R are true, but R is not the correct explanation of the A.
(c) A is true, but R is false.
(d) A is false and R is true.
(e) Both A and R are false.

48. Assertion (A): Bubble sort is faster than selection sort for smaller datasets.
Reason(R): Bubble sort swaps adjacent elements repeatedly, leading to a faster convergence.

49. Assertion (A): [Link]('A') returns true.

2024-25/Grade X/Computer Application Page 6 of 12


Reason (R): The character 'A' is not a digit. a3

50. Assertion (A): [Link]() can merge more than two strings in one call.
Reason (R) : concat() accepts only one argument, so chaining/nesting is required for multiple strings.

Q2: Answer the Questions as Directed: [50]

1. Case Study: A countdown timer is implemented using a do-while loop. The timer starts at 10 and stops
when it reaches 0, displaying each countdown step. The code for the same is given below.
Fill in the blank with correct answer. [2]
int countdown = 10;
do {
[Link]("Time: " + countdown);
blank1;
} while (blank2);
[Link]("Timer Finished!");

2. Case Study: A game provides bonuses every 5th level up to level 50. snippet is written using a for loop
to determine the levels where bonuses are awarded. A statement is written to skip levels that do not award
bonuses.
Based on the above information fill in the blank with correct answer. [2]

for (int level = 1; blank1; level++) {


if (level % 5 != 0)
blank2;
[Link]("Bonus awarded at Level: " + level);
}

3. A student registration system requires checking eligibility based on age. If the age is less than 18, they
not eligible else print eligible. Write the snippet to print the message. Use Ternary operator ? [2]
Solution: String str=(age>=18)?”Eligible”: “Not eligible”;

4. A user wants to calculate the area of a circle using the radius provided as input. If the radius is
𝑟 , write a Java expression using Math methods to calculate the area. for pi use the built in value/variable
and not the constant value. [2]
Solution: double area=[Link]*[Link](r,2);

5. Study the following code and complete the blanks : [2]


class Main {

int addNumbers(int a, int b)// method 1


{

int sum = a + b;
blank1;// return value of addition
}
public static void main( )
{

int num1 = 25;


int num2 = 15;
Main obj = new Main();
int blank2 = [Link](blank3); // calling method
2024-25/Grade X/Computer Application Page 7 of 12
[Link]("Sum is: " + result);

}}
6. Scenario based Question: [3]
Mr. Dominnoo’s has a party at his place . He places an order for pizza. Here is the description:
• Total pizza cost: $23.57
• Number of slices per pizza: 8
• Number of guests: 12
He writes a code to calculate:
• The cost per slice (using [Link])
• The number of whole pizzas needed (using [Link])
• The number of slices left over (using [Link])
Here is the code for the same, fill in the blank with appropriate answers(use variables only)

public class PizzaParty {


public static void main( ) {
// Given values
double totalPizzaCost = 23.57;
int slicesPerPizza = 8;
int numberOfGuests = 12;

// Calculate cost per slice using [Link]


double costPerSlice = [Link]((blank1) * 100.0) / 100.0;
[Link]("Cost per slice: $" + costPerSlice);

// Calculate number of whole pizzas needed using [Link]


double totalSlicesNeeded = numberOfGuests;
double numberOfPizzasNeeded = [Link](blank2);
[Link]("Number of whole pizzas needed: " + (int) numberOfPizzasNeeded);

// Calculate number of slices left over using [Link]


int totalSlicesAvailable = (int) numberOfPizzasNeeded * slicesPerPizza;
int slicesLeftOver = blank3 [Link](totalSlicesAvailable - totalSlicesNeeded);
[Link]("Number of slices left over: " + slicesLeftOver);
}
}

7. Find the output for the following snippet: [3]


int i=4;char ch='e';
[Link](i--+ch);
[Link](i+ch++);
[Link](ch+"\t"+i);

8. Study the snippet and answer the question that follows: [4]
class Operation
{
int data;
void change(int data)//method 1
{
data=data+100 ;
}
void change(Operation op)// method 2
{

2024-25/Grade X/Computer Application Page 8 of 12


[Link]=[Link]+100 ;
}

public static void main( )


{
Operation op=new Operation(); //object 1

[Link]("Value 1: "+[Link]);
[Link](500);

[Link]("Value 2: "+[Link]);

Operation op1=new Operation (); //object 2

[Link]=50;
[Link]("Value 3: "+[Link]);
[Link](op1);
[Link]("Value 4: "+[Link]); }}

1. In which way method 2 is invoked ? [1]


2. What type of function is method 1? [1]
3. What is the output of the above snippet? [2]

9. Display the output for the following: [2]


String name1 = "Franklin Delano Roosevelt";
int blank1 = [Link](' ');
int blank2 = [Link](blank1 + 1).indexOf(' ');
name1 = [Link](blank1 + 1, blank1 + 1 + blank2);
[Link]("*" + name1 + "*");

10. Study the following code and answer the question which follows: [3]
class PrintNumbers
{
public static void main()
{
int a[] = {5};
int x = a[0];
while (x >= 0)
{
process(a);
x = a[0];
x--;
[Link]("x = " + x);
} }

private static void process(int[] a)


{
int x = a[0]--;
x++;
}
}

a) In which way is method process invoked and what type of function is method process? [1]
b) What is the output of the above code? [2]
2024-25/Grade X/Computer Application Page 9 of 12
11. Predict the output for the following: [1]
String n[] = {"OBJECT","ORIENTED","PROGRAMS"};
int len= [Link]-1;
[Link](n[len].substring(3).endsWith("GRA"));

12. Case Study:


A school stores the grades of 5 students in 4 subjects. Following snippet is written to calculate the total
and average grade for each student. fill in the blank with appropriate statements. [2]

import [Link];

public class StudentGrades {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int[][] grades = new int[5][4];

// Calculate total and average grades for each student

for (int i = 0; i < 5; i++) {


int total = 0;
for (int j = 0; j < 4; j++) {
blank1; //to calculate the total
}
blank2;// to calculate the average
[Link]("Total for Student " + (i + 1) + ": " + total + ", Average: " + avg);
}}

13. Sanjay has written the following code to accept the input from the user and perform the addition of
the two values entered. When the code was executed, he was getting the concatenation as the output.
Make the changes and rewrite the code so as to get the correct output.
Input has to be a String value . [2]
// snippet:
Scanner sc=new Scanner([Link]);
[Link]("Enter first String");
String str=[Link]();
[Link]("Enter second String");
String str1=[Link]();
[Link](str+str1);

14. Re-write the following code using exit controlled loop: [2]
int m=10,n=5;
while(m<=20)
m++;
n++;
[Link](m+n);

15. What will be the output of the following code and how many times the loop will be repeated: [2]
int m=10,n=5;
while(m<=20)
m++;
n++;
2024-25/Grade X/Computer Application Page 10 of 12
[Link](m+n);

16. Rewrite the following code using simple if statement: [2]


if([Link](“mine”))
[Link](“BEST”);
else if([Link](“MINE”))
[Link](“BEST”);

17. Evaluate the given expression when the value of a = 2 and b = 3. [2]
b += a++ – ++b * ++a;
[Link](“a = ” + a);
[Link](“b = ” + b);

18. How many times will the following loop executes? Write the output of the code. [2]
int x = 10;
while(true)
{
[Link](x++ * 2);
if(x%3 == 0)
break;
}

19. The output of a which extracts a part of the string “SITHARAMAN” is as follows: [2]
(a) “RAM”
(b) “RAMAN”
Write appropriate Java statements to get the above outputs.

20. Arjun has developed a program to display only the alphabets stored in a character array. Below is the
segment of his program, which has some errors. Check for the statements with errors and write the
correct statements. [2]
char ch[ ] = {‘D’, ‘#’, ‘E’, ‘1’, ‘S’};
for(int i=0 ; i<=[Link]( ) ; i++)
if([Link](ch[i]))
[Link](ch[i]);

21. Consider the following program segment which find the sum of elements in left diagonal and the
product of elements in right diagonal: [2]
int arr[ ][ ] = {{1, 2, 3} , {4, 5, 6} , {7, 8, 9}};
int sld = 0, prd = 1;
for(int i=0 ; i<3 ; i++)
blank(a)
for( _blank (b))
prd = prd * arr[i][j];
[Link](“The sum of elements in left diagonal = ”+sld);
[Link](“The product of elements in right diagonal = ”+prd);
Fill in the blanks (a) and (b) with appropriate Java statements.

22. Write the output of the following: [2]


String s1 = “BEST”, s2 = “REST”;
(a) [Link]([Link](0) == [Link]([Link]( ) – 1));
(b) [Link]([Link](s2));

23. Name the following: [2]


2024-25/Grade X/Computer Application Page 11 of 12
(a) Method with the same name as of the class and is used to initialise the data members.
(b) The access specifier that gives access to all classes in the same package and any sub classes that
are in other packages.

2024-25/Grade X/Computer Application Page 12 of 12

You might also like