Page 266 - Computer science 868 Class 12
P. 266
8. ………………… is the process of defining functions/methods which have the same name but different numbers and types of
parameters.
9. Object is a ………………… unit of Object-Oriented Programming.
10. Data members and variables declared as ………………… can be accessed only from within the scope of the class.
C. Answer the following questions:
1. Define method header.
2. What is Parameterised constructor?
3. What does "int compareTo(String st)" do?
4. What does "String concat(String st)" do?
5. String s="Computer Science";
System.out.println(s.charAt(6));
What does the above code return?
6. double n=Double.parseDouble("4.5");
System.out.println(n);
What is the output of the above code?
7. What will be the output of the following:
String st="We study in class 12";
int v=st.lastIndexOf('s');
System.out.println("The index value is :" +v);
8. if(Character.isUpperCase(ch)) - What does the given snippet do?
9. Math.max(Math.sqrt(25),Math.pow(3,2)) - What does the given snippet do?
10. What does random() method do?
11. Explain default constructor.
12. State the difference between Constructor and Method.
13. Define Copy constructors. Give example.
14. Why do we need a constructor as a class member?
15. Does constructor return a value?
16. Identify the correct output of the following Java program with an empty return statement.
public class TestingMethods2
{
void show()
{
System.out.println("SHOW Method..");
return;
}
public static void main(String[] args)
{
TestingMethods2 t2 = new TestingMethods2();
t2.show();
}
}
17. Identify the output of the following Java program with a “this” operator.
public class function
{
int cakes=5;
void order(int cakes)
{
this.cakes = cakes;
}
public static void main(String[] args)
{
function f = new function();
f.order(10);
264264 Touchpad Computer Science-XII

