Practice TestsICSEClass 10Computer Applications

ICSE Class 10 MCQs on User-Defined Methods and Constructors (with Answers)

Two printable ICSE Class 10 Computer Applications MCQ worksheets on user-defined methods (functions) and constructors in Java, with answers, worked examples and the key rules you must remember for the board exam.

8 min read
ICSE Class 10 MCQs on User-Defined Methods and Constructors (with Answers)

User-defined methods and constructors are two of the most important chapters in ICSE Class 10 Computer Applications. They appear in Section A as MCQs and short answers, and almost every Section B program uses them. This post gives you two MCQ worksheets prepared by Trushna Tejwani for her Class 10 students, plus a quick revision of the rules they test.

What's in the worksheets

  • Worksheet 1 – User-defined methods MCQ: return values, return types, formal and actual parameters, method prototypes, pure and impure methods, and call by value. Answers are given for the questions.
  • Worksheet 2 – Constructors MCQ: what a constructor is, the this keyword, parameterised constructors, constructor and method overloading, tokens, and the Math class.

Download both PDFs below, attempt them without notes, and then check your answers.

Key rules to remember

User-defined methods

  • A method can return only one value, using the return statement.
  • If a method returns a value, the value must match the return type in its prototype. A method that returns nothing has the return type void.
  • Formal parameters appear in the method definition. Actual parameters are the values passed when the method is called.
  • A pure method does not change the state of an object. An impure method changes the values of data members.
  • Primitive values are passed by value, so changes inside the method do not affect the caller's variable.

Constructors

  • A constructor has the same name as the class and no return type, not even void.
  • It is called automatically when an object is created with new.
  • If you do not write any constructor, Java supplies a default constructor.
  • Constructors can be overloaded, just like methods.
  • this refers to the current object.

Worked example

Q. Which is the correct constructor for class Cartoon that takes an int and a double?

  • (a) void Cartoon(int a, double b)
  • (b) int Cartoon(int a, double b)
  • (c) Cartoon(int a, double b)
  • (d) public Cartoon(int a, int b)

Answer: (c). A constructor never has a return type, so (a) and (b) are wrong, and (d) has the wrong parameter types.

class Cartoon {
    int episodes;
    double rating;

    Cartoon(int a, double b) {   // parameterised constructor
        episodes = a;
        rating = b;
    }
}

How to use these worksheets

  1. Revise the rules above for 10 minutes.
  2. Attempt each worksheet in one sitting, aiming for about a minute per question.
  3. Mark your answers and rewrite every wrong one with the correct reason.

Once you're comfortable, try a full paper from our ICSE Class 10 sample papers to practise these topics in the board-exam format.

Download the papers

User-Defined Methods MCQ (with answers)

PDF · 54 KB

Download PDF

Constructors MCQ Worksheet

PDF · 50 KB

Download PDF
Read the questions as text
User-Defined Methods MCQ (with answers) (a)How many values can a method return ? 1. Any number of values 2. Two values 3. Only 1 value 4. Three values Ans) Only 1 value (b) If a method returns a value, then it must be 1. The same data type as defined in its prototype 2. void type 3. int type 4. boolean type Ans) The same data type as defined in its prototype (c) A method that does not return a value has a _______________ return type. 1. boolean 2. class 3. int 4. void Ans) void (d) Parameters in the method definition are called 1. Formal parameters/ Dummy parameters 2. Actual parameters 3. Informal parameters 4. void parameters Ans) Formal parameters/ Dummy parameters (e) The parameters that are passed to the method when it is invoked, are called 1. Formal parameters 2. Actual parameters 3. Informal parameters 4. void parameters Ans) Actual Parameters (f) It helps in dividing complex programs into manageable code blocks. 1. Methods 2. main() 3. Loop 4. Conditional Statements Ans) Methods (g) Invoking a function by passing the objects of a class is termed as 1. Call by value 2. Call by reference 3. Call by Method 4. Call by Variable Ans) Call by reference (h) The scope of a local variable is limited to the 1. Windows 2. Class 3. Multiple Programs 4. Method or block it is declared in Ans) Method or block it is declared in (i) The process of calling a function in such a way that the change in the formal arguments reflects on the actual parameter is known as 1. call by reference 2. call by value 3. call by method 4. none Ans) call by reference (j) A function with many definitions 1. Multiple functions 2. function overloading 3. floating function 4. none 1 . What is a function with the same name as that of its class is called? Constructor Constructor overloading Function Function overloading 2. Which keyword is used to refer the currently calling object? this new returm final 3. What is the correct constructor definition of class Cartoon that has a int and double as parameter? Cartoon (int a, double b) void Cartoon (int a, double b) int Cartoon (int a, double b) public Cartoon (int a, int b) Clear selection 4. What is the smallest individual unit in Java program called? Tokens Literals Identifiers Symbols 5. Where do methods reside in Java? Package Classes Objects Main methods Clear selection 6. The Math class is part of which Java library package? java.util java.io java.math java.lang 7. The parameters appearing in function call statements are called_______. Actual parameters Formal parameters Call parameters All the above 8. Which of the following statement is a method invocation statement? System.out.println("Java"); costPrice=45; void main(int A, double B) int getCost(float price) 9.The function call in which the data in actual parameters get changed is known as: Call by value Return by value Call by reference Return by reference Clear selection 10. Which keyword turns a variable declaration into constant declaration? constant Constant Final final 11.Which entity of the objects, that is represented through functions are called methods? Characteristics Behaviour Parameters All the above Clear selection 12.What type of constructor takes no arguments? Parameterized constructor Non parameterized constructor Overloaded constructor None of these 13. Function not returning any value has return type as: int char float void 14. Which of the following does not represent a character literal? '\a' 'a' '1' "a" 15. The parameters appearing in function definition are called _____________ parameters. Actual parameters Formal parameters Call parameters All the above 16. The function call in which the data in actual parameters remain unchanged is known as: Call by value Return by value Call by reference Return by reference 17. Which among the following is the prototype of the function "sum" that takes an integer variable (x) as its argument and returns a value of float data type. float num(int x) int sum(float x) float sum(int x) int num(float x) 18. What do objects use to interact with one another? Messages Methods Data members class 19. Do the constructor has a return type? No Yes Sometimes Depends on the code 20. Which of the following is an overloaded constructor: Sum(){ } Sum(int a){ } public sum(int a){ } Sum(int a){ } Sum(int a){ } Sum(int name){ } Sum() { } sum(int b) { } 21. If [a=6], give the output of 'a+= a++ + ++a + --a + a; 34 28 32 33 22. A class is a named software representation for an ___________. Construction Inheritance Encapsulation Abstraction Clear selection 23. a%=6 is equivalent to a%6 a*100/6 a=6% a=a%6 24. Which clause is optional in a switch statement? switch case default none 25. Identify the illegal identifier from the following A to Z AtoZ A2Z AtwoZ 26. What type of character sets are used by Java? UK English ASCII US English Unicode 27. What type of function changes the state of its parameters? Pure function Impure function Call function None of the these ―――――――――― Constructors MCQ Worksheet 1.What is a function with the same name as that of its class is called? Constructor Constructor overloading Function Function overloading 2. Which keyword is used to refer the currently calling object? this new returm final 3. What is the correct constructor definition of class Cartoon that has a int and double as parameter? Cartoon (int a, double b) void Cartoon (int a, double b) int Cartoon (int a, double b) public Cartoon (int a, int b) Clear selection 4. What is the smallest individual unit in Java program called? Tokens Literals Identifiers Symbols 5. Where do methods reside in Java? Package Classes Objects Main methods Clear selection 6. The Math class is part of which Java library package? java.util java.io java.math java.lang 7. The parameters appearing in function call statements are called_______. Actual parameters Formal parameters Call parameters All the above 8. Which of the following statement is a method invocation statement? System.out.println("Java"); costPrice=45; void main(int A, double B) int getCost(float price) 9.The function call in which the data in actual parameters get changed is known as: Call by value Return by value Call by reference Return by reference Clear selection 10. Which keyword turns a variable declaration into constant declaration? constant Constant Final final 11.Which entity of the objects, that is represented through functions are called methods? Characteristics Behaviour Parameters All the above Clear selection 12.What type of constructor takes no arguments? Parameterized constructor Non parameterized constructor Overloaded constructor None of these 13. Function not returning any value has return type as: int char float void 14. Which of the following does not represent a character literal? '\a' 'a' '1' "a" 15. The parameters appearing in function definition are called _____________ parameters. Actual parameters Formal parameters Call parameters All the above 16. The function call in which the data in actual parameters remain unchanged is known as: Call by value Return by value Call by reference Return by reference 17. Which among the following is the prototype of the function "sum" that takes an integer variable (x) as its argument and returns a value of float data type. float num(int x) int sum(float x) float sum(int x) int num(float x) 18. What do objects use to interact with one another? Messages Methods Data members class 19. Do the constructor has a return type? No Yes Sometimes Depends on the code 20. Which of the following is an overloaded constructor: Sum(){ } Sum(int a){ } public sum(int a){ } Sum(int a){ } Sum(int a){ } Sum(int name){ } Sum() { } sum(int b) { } 21. If [a=6], give the output of 'a+= a++ + ++a + --a + a; 34 28 32 33 22. A class is a named software representation for an ___________. Construction Inheritance Encapsulation Abstraction Clear selection 23. a%=6 is equivalent to a%6 a*100/6 a=6% a=a%6 24. Which clause is optional in a switch statement? switch case default none 25. Identify the illegal identifier from the following A to Z AtoZ A2Z AtwoZ 26. What type of character sets are used by Java? UK English ASCII US English Unicode 27. What type of function changes the state of its parameters? Pure function Impure function Call function None of the these