Page 488 - Computer science 868 Class 12
P. 488
void show()
{ super.show();
System.out.println("Service Tax:"+tax);
System.out.println("Total Tax:"+taxamt);
}
public static void main(String n,int c,double a)
{ Taxable ob=new Taxable(n,c,a);
ob.cal_tax();
ob.show();
}
}
5. (i) The concept in Java to perform method overloading and method overriding is called: [ISC 2022]
(a) inheritance (b) polymorphism
(c) data abstraction (d) encapsulation
Ans. (b)
(ii) The interface in Java is a mechanism to achieve: [ISC 2022]
(a) encapsulation (b) overriding
(c) polymorphism (d) abstraction
Ans. (d)
(iii) System.out.println("Computer Science”.lastIndexOf('E')); [ISC 2022]
(a) 8 (b) 7
(c) -1 (d) 15
Ans. (c)
(iv) Write a statement in Java to extract the last four characters from the word “SIMPLICITY”. [ISC 2022]
Ans. System.out.println("SIMPLICITY".substring(6));
(v) Name a data structure the follows LIFO principle and one that follows FIFO principle. [ISC 2022]
Ans. LIFO – STACK
FIFO – QUEUE
(vi) What is the output of the program code given below, when the value of x=294? [ISC 2022]
int simple(int x)
{ return (x<=0)? 0: x + simple(x/10);}
Ans. 325
(vii) State any one drawback of using recursive technique in a Java program. [ISC 2022]
Drawbacks of using recursive program are as follows:
Ans. a. Recursion uses more memory.
b. Recursion can be slow.
6. A super class Item has been defined to store the details of an item sold by a wholesaler to a retailer. Define a subclass Taxable
to compute the total amount paid by the retailer along with service tax. [ISC 2022]
Some of the members of both the classes are given below:
Class name : Item
Data Members/Instance variable
name : to store the name of the item
486486 Touchpad Computer Science-XII

