0% found this document useful (0 votes)
40 views3 pages

Mock Test 1

1. The document is a mock test for a Computer Science exam with 35 marks total across 3 sections: - Section A has 7 multiple choice questions worth 1 mark each - Section B has 4 short answer questions worth 2 marks each - Section C has 4 programming questions worth between 4-6 marks each 2. Section A covers topics like recursion vs iteration, abstract methods, method overriding, and tree traversals. Section B covers interfaces, function dry runs, and class declarations. Section C involves writing Java programs for palindrome checking, finding Pythagorean triplets, output of a code fragment, and generating a symmetric matrix from a square input matrix. 3. The test covers a range of core

Uploaded by

Arghya Basu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views3 pages

Mock Test 1

1. The document is a mock test for a Computer Science exam with 35 marks total across 3 sections: - Section A has 7 multiple choice questions worth 1 mark each - Section B has 4 short answer questions worth 2 marks each - Section C has 4 programming questions worth between 4-6 marks each 2. Section A covers topics like recursion vs iteration, abstract methods, method overriding, and tree traversals. Section B covers interfaces, function dry runs, and class declarations. Section C involves writing Java programs for palindrome checking, finding Pythagorean triplets, output of a code fragment, and generating a symmetric matrix from a square input matrix. 3. The test covers a range of core

Uploaded by

Arghya Basu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Mock Test 1

Computer Science

FM: 35
Time: 1 hr. 30 minutes

Answer the following questions. The number within brackets beside every section
represents the concerned score.

Section A (7 x 1 = 7 marks)

1. Give one advantage of using recursion over iteration.


2. What is an abstract method?
3. Define overriding.
4. “Constructor of the derived class gets executed before the constructor of the base
class” - is it true or false?

5. N-L-R represents (N = Root, L=Left Child, R=Right Child)


(i) In-order
(ii) Pre-order
(iii) Post-order
(iv) None

6. Give the output of the following string methods:


"SUBMISSION ".indexOf('S')+ " SUBMISSION ".lastIndexOf('I')

7. Write the statement in Java to extract the word “NATION” from the word “ASSASINATION”.
Section B (4 x 2 = 8 marks)

8. What is an interface? How is it different from a class?

9. The following function Check() is a part of some class. What will the function Check()
return when the values of both ‘m’ and ‘n’ is equal to 5? Show the dry run/working.

int Check (int m, int n)


{
if(n = = 1)
return - m --;
else
return + + m + Check (m, -- n);
}
10. From the class declaration given below, state the nature of the identifiers A, B, C and
D:
class A extends B implements C, D

11.
P

B R

S T U V

X Y

Observe the above tree and write the Pre-order and In-order traversal sequences.
Section C (4 x 5 = 20 marks)

12. Write a program in Java to accept some word and check if it is a palindrome. 4

13. Write a program in Java to take a positive integer ‘n’ as input to find out all the
Pythagorean triplets <a, b, c> such that a<b<c and a2 + b2 = c2, within 1 to ‘n’. 6

14.Find output: 4

Find output of the following code fragment:

class Q1{

public static void main(String args[]){


int a=4;
int b=8;
if((b-a--)>=a)
{
if((b+a)%2==1)
System.out.println(a*b);
else
System.out.println(b+a);
}
}

15. Write a program in Java to accept a square matrix A of order ‘n’, to be taken as input
and to generate a symmetric matrix, using A. 6

You might also like