Computer Applications
Why is a class known as composite data type?
Java Classes
ICSE 2009
120 Likes
Answer
A composite data type is one which is composed with various primitive data types. A class can contain various primitive data types as its data members so it is known as a composite data type.
Answered By
60 Likes
Related Questions
Fill in the blanks:
_________ members are accessible in its own class as well as in a sub class.
Given below is a class based program to accept name and price of an article and find the amount after 12% discount if the price exceeds 10,000 otherwise, discount is nil. There are some places in the program left blank marked with ?1?, ?2?, ?3? and ?4? to be filled with appropriate keyword/expression.
class Discount ( int pr; double d, amt; String nm; Scanner ob = ...?1?... Scanner(System.in); void input( ) { System.out.println("Enter customer's name:"); nm = ...?2?... ; System.out.println("Enter price of the article:"); pr = ob.nextInt( ); } void calculate() { if (...?3?...) d= ...?4?... ; else d = 0; amt = pr - d; } void print() { System.out.println("Name =" + nm); System.out.println("Amount to be paid=" + amt); } }
Based on the above discussion, answer the following questions:
(a) What will be keyword /expression filled in place of ?1?
(b) What will be keyword/expression filled in place of ?2?
(c) What will be keyword /expression filled in place of ?3?
(d) What will be keyword /expression filled in place of ?4?
Name the types of data used in a class.
What is the purpose of the new operator?