ruhi
BAN USER
- 0of 0 votes
AnswersDefine a class Marks as having the fields marks1, marks2, marks3 and maxMarks all of type int.
- ruhi in United States
In the class Marks
- define a constructor of the class whch takes 3 ints as input and assigns them to marks1, marks2 and mark3 respectively. It aslo assigns the maximum of marks1, marks2 and marks3 to maxMarks.
- define a method getMaxMarks() which returns the maximum of marks1, marks2 and marks3.
- define a method isPass() which returns true if the average of marks1, marks2 and marks3 is at least 40.
Define a class StudentList which has the field allMarks(of type Marks[]). In the class, define the methods
- totalStudents() which returns the number of total students which is the number of objects in the array allMarks
- passCount() which returns the number of students who have passed.| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
AnswersDefine a class Point having 2 fields x (int) and y (int) which represents a point (x,y)
- ruhi in United States
Define a class Line having 2 Points, pt1 and pt2.
Define a class Quadrilateral having 4 Points, pt1, pt2, pt3 and pt4. The class also has the following functions
- getAllLines() which returns a Line[] consisting all 4 lines of the Quadrilateral. Note that the 4 lines of the quadrilateral will be pt1:pt2, pt2:pt3, pt3:pt4 and pt4:pt1
- longestSide() which return a Line that represents the longest the side of the Quadrilateral.
Also define the constructors for each class| Report Duplicate | Flag | PURGE
Accenture Java Developer - 0of 0 votes
AnswerDefine the following classes
- ruhi 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 - 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 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
AnswersA game is being played with the following rules :
- ruhi in United States
- The first player says 1, the next 2 and so on.
- If a number is a multiple of 4 or 7 then that number is skipped and the next number is spoken. However if the number is a multiple of both 4 and 7 then the number is not skipped.
Define a function which taken a number n as input and returns the nth number which will be spoken.
nthNumber(10) = 15 (the order of numbers spoken is 1,2,3,5,6,9,10,11,13,15)| Report Duplicate | Flag | PURGE
- 0of 0 votes
AnswersGiven an array of strings as input, return an array of all strings that have repeated chars that appear together. For e.g. in "hello" l and in "summer" s is a repeated char that appears together. However in "robot" o is not a repeated char as it does not appear together.
- ruhi in United States
repeatChars({"hello","robot","summer","elephant"}) = {"hello","summer"}| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 2of 2 votes
AnswersYou have been given an array of int as input. Return true if there exist 2 numbers in the array whose sum is equal to the sum of the rest of the numbers in the array.
- ruhi in United States
twoSum({2,11,5,1,4,7}) = true (11+4 = 2+5+1+7)| Report Duplicate | Flag | PURGE
Amdocs
array length is same.remove null too
- ruhi July 25, 2014