Page 264 - Computer science 868 Class 12
P. 264
9. The method ………………… returns the largest integer value smaller than the number in double data type.
10. In …………………, the values of actual parameters are copied to formal parameters.
Answers
1. functions 2. user-defined methods 3. parameterised 4. static binding 5. startsWith
6. substring(int index) 7. parseInt() 8. character 9. Math.ceil() 10. pass by value
C. Answer the following questions:
1. What are the two types of methods?
Ans. Two types of methods are Built-in methods and User-defined methods.
2. Define user-defined method.
Ans. The methods created by the users or the programmers known as user-defined methods.
3. State the following for the given statement "public static void perfect(int n)".
• name of the method
• return type of the method
• parameter of the method
Ans. • name of method: perfect
• return type of the method: void
• parameter of the method: n
4. How does the method act?
Ans. The method acts as an abstraction for complex user-defined operations on objects.
5. What is Access Specifier?
Ans. Access Specifier defines the access scope of the variable, methods, and classes and here the access scope means the area or
space where a variable or classes or methods are accessible.
6. What is a pure method?
Ans. A pure function does not change the state of an object and also returns a value to the function from where it is called which
depends on the input parameters.
7. What is the difference between Arguments and Parameters?
Ans. Variables when appearing in caller method are known as arguments and when appearing in method definition it is said to be
Parameters.
8. Name the different ways of defining a function.
Ans. The different ways are
• Methods with parameters
• Methods without parameters
• Methods with return statement
• Methods without return statement
9. Why are mathematical methods used?
Ans. Mathematical methods are used in programs to calculate mathematical functions.
10. What does Math.cbrt() method do?
Ans. Math.cbrt() method returns the cube root of the number passed in the argument.
D. Assertion and Reasoning Based Question.
Assertion: Constructor is used to execute the Java code which performs a specific job.
Reason: Constructor can be invoked only once at the time of creating the object.
(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) Assertion is false and Reason is true.
Ans. Simple method is used to execute the Java code which performs a specific job.
262262 Touchpad Computer Science-XII

