Amdocs Interview Report
- 0of 0 votes
AnswersDefine a class Passenger having the fields name (String), age (int), gender (char : M/F), weight (int). Define 2 constructors for this class, one with parameters and one which has no parameters.
- ruhi July 30, 2014 in United States
Also define a class Train in which there are the following functions. Note that there are no fields in the class Train.
- int getTotalWeight(Passenger[] passengers) - returns the total weight of all the passengers in the input
- int countChildren(Passenger[] passengers) - returns the number of children in the input passengers. A child is defined as age 12 or below
- int countGender(Passenger[] passengers, boolean male) - returns the number of males if true else returns the number of females. A male has the gender 'M' and a female 'F'
- Passenger[] addPassenger(Passenger[] passengers, Passenger passenger1) - returns a Passenger[] which contains all the passengers and also passenger1.| Report Duplicate | Flag | PURGE
Amdocs - 0of 0 votes
AnswerDefine the following classes
- ruhi July 30, 2014 in United States
- Book which has the fields title(String), author (String), count (int). Also define the following function in the class
increment() : increases count by 1.
decrement() : reduces the count by 1. If count is 0, it remains 0.
- Library which has a field books (of type Book[]). It also has the following functions
getCount(String title) : given the title of a book as parameter, return how many copies of the book are there in the library
getCount(Book book) : given the object of type Book as parameter, return how many copies are there of that book in the library
getCount() : returns the total number of books in the library
getDiffCount() : returns the number of different books in the library
addBook(Book book) : given an object of type Book as input, increment its count if it is in the library else adds the book.
removeBook(Book book) : given an object of type Book as input, decreases the count of that book if it exists in the library. If the count becomes 0, it is removed.| Report Duplicate | Flag | PURGE
Amdocs