Page 143 - Computer science 868 Class 12
P. 143
C. Answer the following questions:
1. Write any two drawbacks of procedure-oriented programming languages.
2. Write any two real life examples of superclass and subclass.
3. Write any two advantages of object-oriented programming language.
4. Define class and object.
5. Why the object is an instance of a class?
6. Define data hiding.
7. Define abstraction.
8. What do you mean by encapsulation?
9. Write the syntax to create an object of a class.
10. Write any two differences between POP language and OOP language.
Previous Years' Questions
1. State any one purpose of using the keyword this in Java programming. [ISC 2023]
Ans. ‘this’ keyword is a reference variable that refers to the current object on which a method or constructor is being called. It’s
essentially a way for an object to refer to itself within its own scope.
2. What is the output of the code given below? [ISC 2022]
void main()
{ int s=1, c;
for(int i=1 ;i<=3;i++)
{ c=i;
while(c!=0)
s=s*c--;
}
System.out.println(s);
}
(a) 18 (b) 12
(c) 36 (d) 4
Ans. (b)
3. Differentiate between a constructor and a method of a class. [ISC 2017]
Ans. Constructor is a member method with the same name as that of the class. It used to initialise the instance variables of the objects.
Constructor name must be same as the class name. The constructor must not have a return type.
The method is used to expose the behaviour of an object. Method name may or may not be the same as a class name. The
method must have a return type.
141
Programming in Java 141

