Computer Applications
Name the types of data used in a class.
Java Classes
40 Likes
Answer
- Access Specifiers
- Instance Variables
- Class Variables
- Local Variables
- Constructors
- Member Methods
Answered By
20 Likes
Related Questions
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?
Why is a class known as composite data type?
What is the purpose of the new operator?
Can a class be referred to as user defined data type? Comment.