Skip to main content

Arrays, Object and Classes Concepts in Java | Practice Questions

Trainee Class Methods

Refer the below Class outline and implement the methods

public boolean findTrainee(Trainee trainee[],int traineeId)
public Trainee getTrainee(Trainee trainee[],int traineeId)
public int getCount(Trainee trainee[],String location)
public Trainee[] getAllTrainees(Trainee trainee[],String sequence)
public int[] getAllId(Trainee trainee[])

Toy Class

Create Class Toy with below attributes

name 
category 
price
discount

Create Class ToyDemo with main method. Create four toy objects with relevant data. Two objects should have category as “fruits” and other two objects should have category as “animal”. Write a method in this class which will take all four toy objects as input. Additionally, it will also take category name as input. This method should return least price toy name (considering the discount as well) for specified category. If there is no specific category (e.g category as “fruits”, method should return message “no category found”.

Follow class outline diagram as given below. Ensure class attributes are private and other methods are public. Use package “com” to build your solution.

NOTE: Use .equals for comparing String values instead of == operator. Search on net and find out why. Else discuss among colleagues.

Car Class

Create class Car with below attributes: make

model
passenger
Capacity 
onRoadPrice

Create class CarDemo which has main method. Create another method - getBestCar in this class which will take four car objects and additional parameter as compareType. Value of this parameter can be ‘c’ or ‘p’, where ‘c’ stands for capacity of passengers and ‘p’ stands for on road price. This method will return make and model name for highest value of ‘c’ or ‘p’ (with – character in between. E.g for make – Hyundai and model – santro, method should return “Hyundai-santro”). Create four objects of Car class in main method and drive it through getBestCar method.
Follow class outline diagram as given below. Ensure class attributes are private and other methods are public. Use package “com” to build your solution.

Credit Card Company Class

Create class Customer with below attributes:

custId 
accountId
creditCardCharges

Create another class CreditCardCompany which has a method which takes Customer object as parameter and returns the payback amount for the credit card charges value for that customer. Use below logic to calculate payback amount:

a) 0.25% for charges up to Rs. 500.
b) 0.50% for the next Rs.1000 (that is, the portion between Rs. 500 and Rs. 1500),
c) 0.75% for the next Rs.1000 (that is, the portion between Rs. 1500 and Rs. 2500),
d) 1.0% for charges above Rs2500.

Thus, a customer who charges Rs. 400 a year receives Rs.1.00, which is 0.25 • 1/100 • 400, and one who charges Rs1, 400 a year receives Rs. 5.75, which is 1.25 = 0.25 • 1/100 • 500 for the first Rs. 500 and 0.50 • 1/100 • 900 = 4.50 for the next Rs. 900. Determine by hand the pay backs amount for a customer who charged Rs. 2000 and one who charged Rs. 2600.

Create another class as CreditCardDemo which will have main method. Within main method, create object of CreditCardCompany. Create 5 customer objects with relevant data. Call the method to return payback amount for each customer and display the same

CONTACT DETAILS

For any other questions or other tasks please feel free to contact me
via email: mhassnainjamil@gmail.com
via WhatsApp: +92-324-7042178
via skype: hassnainjamil1

Comments

Popular posts from this blog

The Zoo Management System - entity relationship diagram & MS Access Database

Zoo Management System - Project Details: You are the employee of a big, worldwide working Zoo Management Company. Your company is responsible for the Zoo management. Your boss thinks it would be a great idea to store all data for each Zoo in a brand new self-developed ZOO Management System. Up to now, the ZOO management company has maps of each ZOO available. Your boss knows that you took a course in introduction on an ERP system, so he asks you if you could help designing such a system. Each ZOO must have the same organizational structure, which should look like this: Each Zoo has a Zoo-Address. Each Zoo has many visitors (Visitor Ticket Process (VTP). Many Zoo-Attractions belong to a Zoo. Module 1: Entity Relationship Diagram Design a ER (entity-relationship) diagram for your ZOO Management System. Use the information provided below with the entities and its attributes. Put the entities in the correct relationship to each other (organizational structure). Module 2: DB Implem...

EIT Knowledge and Innovative Community Scholarships has been announced

Admission Criteria To qualify for our programmes, applicants need to fulfill the admission requirements based on previous studies, English proficiency and relevant documentation. Previous Studies: A Completed Bachelor’s Degree In order to be admitted into a KIC InnoEnergy MSc programme, you must have completed a Bachelor’s degree encompassing a minimum of 180 ECTS credits or equivalent academic qualifications from an internationally recognized university. Please note that admissions depend on the specific BSc degree you hold for entry into the MSc programme you are interested in. Conditional Acceptance – Undergraduate Students in Final Year Students in their final year of undergraduate education may also apply and if expected to qualify, receive a conditional offer. If you have not completed your studies, please include a written statement from your university’s administration office (or equivalent department), confirming that you are enrolled in the final year of your study programme ...

Human Physiology by Stuart Ira Fox [PDF] (12th edition) free download