Prashnikaप्रश्निका
Code
About
Computer ScienceClass 12

Methods - ISC Class 12 Computer Science Questions with Answers

13 past-paper questions on Methods from ISC Class 12 Computer Science papers (2026-2022), newest first, in full. Tap "Show answer" under a question to see its answer. The syllabus covers Methods as abstractions, Formal and actual arguments, Static methods and variables, The this operator and Algorithmic problem solving using methods.

13questions
5years
2026newest
20261 question
1 mark · Assertion-reasonOpen: The return statement enables the exit of the program control from the current…

Study the Assertion and Reason and choose the correct option.

Assertion: The return statement enables the exit of the program control from the current method.

Reason: If a method's return type is void, it can still contain return 0 statement to return nothing.

  • (a)Both Assertion and Reason are true and Reason is the correct explanation for Assertion.
  • (b)Both Assertion and Reason are true but Reason is not the correct explanation for Assertion.
  • (c)Assertion is true and Reason is false.
  • (d)Both Assertion and Reason are false.
Show answer

Answer

Correct option: (c)

Answer: (c) Assertion is true and Reason is false. The return statement terminates execution of the current method and returns control to the caller (Assertion is true). However, a method with return type void cannot return any value; 'return 0;' causes a compilation error (Reason is false).
20251 question
1 mark · MCQOpen: Consider the following code statement: public class Person { int age; public…

Choose the correct option.

Consider the following code statement:
public class Person
{ int age;
    public Person (int age)
    { 
        this.age = age;
    }
}
Which of the following statements are valid for the given code? I. The keyword this in the constructor refers to the current instance of the class. II. The keyword this differentiates between the instance variable age and the parameter age. III. The keyword this can be used only in constructors.
  • (a)Only I and II
  • (b)Only II and III
  • (c)Only I and III
  • (d)Only III
Show answer

Answer

Correct option: (a)

Answer: (a) Only I and II The keyword 'this' refers to the current object's instance (I is true) and is commonly used to distinguish an instance variable from a parameter of the same name (II is true). However, 'this' can be used in any instance method, not only in constructors, so III is false.
20242 questions
1 mark · Short answerOpen: State any one difference between instance variable and class variable.

Answer the following.

State any one difference between instance variable and class variable.
Show answer

Answer

An instance variable is declared inside a class without the static keyword, and each object of the class gets its own separate copy of it. A class variable is declared with the static keyword, and only one copy of it exists, shared by all objects of the class.
1 mark · Short answerOpen: What is the relevance of the keyword static for a data member of a class

Answer the following.

What is the relevance of the keyword static for a data member of a class
Show answer

Answer

The keyword static, when used with a data member of a class, makes it a class variable instead of an instance variable: only a single copy of that data member is created and it is shared by all objects of the class (rather than a separate copy for each object). Its value persists across all objects and can be accessed directly using the class name, even without creating an object.
20233 questions
1 mark · Short answerOpen: State any one purpose of using the keyword this in Java programming.

Answer the following.

State any one purpose of using the keyword this in Java programming.
Show answer

Answer

The keyword this refers to the current object. It is used to tell an instance variable apart from a local variable or parameter with the same name, e.g. this.num = num; in a constructor. (It can also be used to call another constructor of the same class or to pass the current object as an argument.)
3 marks · Case basedOpen: boolean num(int x) { int a=1; for (int c=x; c>0; c/=10) a *= 10; return…

Answer the following.

boolean num(int x)
{ int a=1;
for (int c=x; c>0; c/=10)
a *= 10;
return (x*x%a)==x;
}
With reference to the code given below, answer the questions that follow along with dry run / working.
(a)[2]
What will the function num() return when the value of $x=25$?
(b)[1]
What is the method num() performing?
Show answer

Answer (a)

Dry run for $x = 25$:
ca
2510
2100
0loop ends
$x*x = 625$, $625 \% 100 = 25$, and $25 == 25$ is true. The function returns true.

Answer (b)

It checks whether x is an Automorphic number, i.e. whether the square of the number ends with the number itself (a is 10 raised to the number of digits of x).
3 marks · Case basedOpen: void Solve(int n) { int a=1,b=1; for (int i=n;i>0;i=i/10) { int d=i%10; if…

Answer the questions on the code given below.

void Solve(int n)
{  int a=1,b=1;
   for (int i=n;i>0;i=i/10)
   { int d=i%10;
     if (d%2==0)
         a=a*d;
     else
         b=b*d;
   }
   System.out.println(a+" "+b);
}
With reference to the code given below answer the questions that follow.
(a)[2]
What will the function Solve( ) return when the value of n=3269?
(b)[1]
What is the method Solve( ) computing?
Show answer

Answer (a)

Solve() is void, so it returns nothing, but it displays "12 27" (verified by running the code for real). Dry run for n=3269: i=3269, d=9 (odd) -> b=1*9=9; i=326, d=6 (even) -> a=1*6=6; i=32, d=2 (even) -> a=6*2=12; i=3, d=3 (odd) -> b=9*3=27; i=0, loop ends. Output: 12 27

Answer (b)

Taking the digits of n one at a time (from the units digit upward), the method computes the product of all the even digits (stored in a) and, separately, the product of all the odd digits (stored in b), and then displays both products.
20226 questions
1 mark · MCQOpen: What is the method solve() performing?

Choose the correct option.

What is the method solve() performing?
  • (i)HCF of ‘a’ and ‘b’
  • (ii)Prime Factors of ‘a’ and ‘b’
  • (iii)LCM of ‘a’ and ‘b’
  • (iv)None of the above
Show the code
int solve(int a, int b)
{
    int i, l = 0;
    for(i = 1; i <= a * b; i++)
    {
        if(i % a == 0 && i % b == 0)
        {
            l = i;
            break;
        }
    }
    return l;
}
Show answer

Answer

Correct option: (iii)

Answer: (iii) LCM of 'a' and 'b' The loop finds the smallest i divisible by both a and b.
2 marks · MCQOpen: What is the output of the method fun() when the value of n=4?

Choose the correct option.

What is the output of the method fun() when the value of n=4?
  • (i)24
  • (ii)72
  • (iii)120
  • (iv)ERROR
Show the code
void fun(int n)
{
    int i, f;
    for(i = 1, f = 1; i <= n; i++, f *= i);
    System.out.print(f);
}
Show answer

Answer

Correct option: (iii)

Answer: (iii) 120 f is multiplied after i is incremented: i=2 f=2, i=3 f=6, i=4 f=24, i=5 f=120, then the loop stops. It prints 120.
2 marks · MCQOpen: What will the method test() return when the value of n=9?

Choose the correct option.

What will the method test() return when the value of n=9?
  • (i)1
  • (ii)true
  • (iii)0
  • (iv)Error
Show the code
int test(int n)
{
    if(n == 1) return 0;
    for (int i = 2; i <= (int)(Math.sqrt(n)); i++)
        if(n % i == 0)
            return 0;
    return 1;
}
Show answer

Answer

Correct option: (iii)

Answer: (iii) 0 For n=9 the loop runs to i=3 and 9 % 3 == 0, so it returns 0.
1 mark · MCQOpen: What is the method fun() performing?

Choose the correct option.

What is the method fun() performing?
  • (i)Checking for Prime Numbers
  • (ii)Product of odd numbers
  • (iii)Factors of a number
  • (iv)Finding the factorial
Show answer

Answer

Correct option: (iv)

Answer: (iv) Finding the factorial The method multiplies f by successive integers, the intended purpose being factorial (though as written it gives the factorial of n+1).
1 mark · MCQOpen: What is the method test() performing?

Choose the correct option.

What is the method test() performing?
  • (i)Prime number/Composite number
  • (ii)Armstrong number
  • (iii)Palindrome number
  • (iv)Perfect number
Show answer

Answer

Correct option: (i)

Answer: (i) Prime number/Composite number The method returns 1 for a prime and 0 for a composite number, testing divisors up to the square root.

About Methods

Methods is a unit of the ISC Class 12 Computer Science syllabus.

The syllabus lists these topics: Methods as abstractions, Formal and actual arguments, Static methods and variables, The this operator and Algorithmic problem solving using methods.

Prashnika has 13 past-paper questions on Methods, from papers of 2022-2026, asked in 5 different years. By kind: MCQ (7), Short answer (3), Case based (2) and Assertion-reason (1). They carry between 1 and 3 marks, and most are worth 1 mark.

To practise, use the paper generator, which can build a practice paper from this chapter.

Common questions

What topics are in Methods in ISC Class 12 Computer Science?

The syllabus lists Methods as abstractions, Formal and actual arguments, Static methods and variables, The this operator and Algorithmic problem solving using methods.

How many questions on Methods are in ISC Class 12 Computer Science past papers?

Prashnika has 13 questions on Methods, from papers of 2022-2026 (board, specimen, improvement and practice papers together).

What kinds of questions are asked on Methods?

By kind: MCQ (7), Short answer (3), Case based (2) and Assertion-reason (1).