Prashnikaप्रश्निका
Code
About
‹ Back to the paper

Question 64

5 marks

Computer ScienceISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024)Case basedInheritance, Interfaces and Polymorphism

Answer the following questions.

Consider the class definitions and answer the questions: Complete the missing parts of the code…

Consider the class definitions and answer the questions:
(a)[3]
Complete the missing parts of the code given below:
class SI ?1? Account     
{                            
    double sINT; 
    public SI (double sP, double sR, double sT) 
    { 
        ?2?                                           
        sINT = 0; 
    } 
    public void Interest() 
    {   
        sINT = (P * R * T) / 100;  
    } 
    public void display() 
    { 
        ?3? //invoke display( ) of base class                
        Interest(); 
        System.out.println("Simple Interest=" + sINT);      
    } 
} // class ends
(b)[2]
Answer the following questions, based on the above code: (i) Name the base class and derived class (ii) Write the prototype of the base class constructor.

Answer

Answer (a)

Blanks: extends; super(sP, sR, sT);; super.display();

?1? extends ?2? super(sP, sR, sT); ?3? super.display();

Answer (b)

(i) Base class = Account, Derived class = SI. (ii) Prototype of the base class constructor: Account(double P, double R, double T)