CLASS X User Defined Methods Worksheet
CLASS X User Defined Methods Worksheet
1. Differentiate between:
a. Call by value and Call by Reference
b. Actual parameter and Formal Parameter
c. Pure function and Impure Function
d. public,private and protected access specifier
e. class variable and instance variable
f. static and non static function
2. Write the prototype of a function check which takes an integer as an argument 2018
and returns a character.
3. A function PosChar which takes a String argument and a character argument and 2016
returns an integer value.
4. 2016
Define a class ParkingLot with following description:
Instance variables/data members
int vno : To store the vehicle number
int hours : To store the number of hours the vehicle is parked in the parking lot
double bill : To store the bill amount
Member Methods
void input(): To input and store vno and hours.
void calculate(): To compute the parking charge at the rate of Rs 3 for the first hour
or part thereof, and Rs 1.50 for each additional hour or part thereof.
void display(): To display the detail
(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
10. Assertion: A user-defined method can be called multiple times.
Reason: A user-defined method can be called multiple times from different parts of
the program.
(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
11. Assertion: A user-defined method can access private data members.
Reason: A user-defined method can access private data members of the same class.
(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
12. Define a class named movieMagic with the following description: 2023
Data Members Purpose
movieMagic() Default constructor to initialize numeric data members to 0 and String data member to
void display() To display the title of the movie and a message based on the rating as per the table giv
Ratings Table
Rating Message to be displayed
Up to 1/2 9
> 1 to 3 years 11
12
> 3 years