Computer Applications
Consider the following class:
public class myClass {
public static int x=3, y=4;
public int a=2, b=3;}
- Name the variables for which each object of the class will have its own distinct copy.
- Name the variables that are common to all objects of the class.
Java Classes
ICSE 2014
13 Likes
Answer
- a, b
- x, y
Answered By
8 Likes
Related Questions
Define a class with the following specifications:
Class name: Bank
Member variables:
double p — stores the principal amount
double n — stores the time period in years
double r — stores the rate of interest
double a — stores the amountMember methods:
void accept () — input values for p and n using Scanner class methods only.
void calculate () — calculate the amount based on the following conditions:Time in (Years) Rate % Upto 1⁄2 9 > 1⁄2 to 1 year 10 > 1 to 3 years 11 > 3 years 12 void display () — display the details in the given format.
Principal Time Rate Amount XXX XXX XXX XXXWrite the main method to create an object and call the above methods.
Design a class name ShowRoom with the following description:
Instance variables / Data members:
String name — To store the name of the customer
long mobno — To store the mobile number of the customer
double cost — To store the cost of the items purchased
double dis — To store the discount amount
double amount — To store the amount to be paid after discountMember methods:
ShowRoom() — default constructor to initialize data members
void input() — To input customer name, mobile number, cost
void calculate() — To calculate discount on the cost of purchased items, based on following criteriaCost Discount (in percentage) Less than or equal to ₹10000 5% More than ₹10000 and less than or equal to ₹20000 10% More than ₹20000 and less than or equal to ₹35000 15% More than ₹35000 20% void display() — To display customer name, mobile number, amount to be paid after discount.
Write a main method to create an object of the class and call the above member methods.
DTDC a courier company charges for the courier based on the weight of the parcel. Define a class with the following specifications:
Class name: courier
Member variables:
name – name of the customer
weight – weight of the parcel in kilograms
address – address of the recipient
bill – amount to be paid
type – 'D'- domestic, 'I'- international
Member methods:
void accept ( ) — to accept the details using the methods of the Scanner class only.
void calculate ( ) — to calculate the bill as per the following criteria:
Weight in Kgs Rate per Kg First 5 Kgs Rs.800 Next 5 Kgs Rs.700 Above 10 Kgs Rs.500 An additional amount of Rs.1500 is charged if the type of the courier is I (International)
void print ( ) — To print the details
void main ( ) — to create an object of the class and invoke the methods