Public static | Computer Science homework help

Q1. [Expected Time: 10 Mins]

Complete the methods of following class Q1 as per commented specification

class Q1

{

public static boolean nameExists(String[] nameList, String name)

{

/*

This method returns true or false depending upon whether name exists in nameList or not. If any of the passed parameter is null or length of any passed parameter is zero then it returns false.

*/

}// End of method nameExists 

public static String getLongestCommonWord(String[] nameList1, String[] nameList2)

{

/*

This method returns the longest common word (highest length) from nameList1 and nameList2. Assume each element of nameList1 and nameList2 is a word. If any of the passed parameter is null or the length of any passed parameter is zero then it returns null. If more than one common word has the same highest length then it can return any one of them. If there does not exist any common word then it returns empty String.

*/

}// End of method getLongestCommonWord() 

}// End of class Q1

[3+7=10 M]

Q2. [Expected Time: 20 Mins]

(a)

Consider a classes named ‘Address’ which encapsulates the address of any particular person having attributes as : – line1 : String , – line2 : String, – line3 : String , – city : char[] , – state : char[] and – pin : String . The class supplies only one parameterized constructor which receives only one parameter of type String which embeds the values of all the attributes in $ separated form as per following format:

“line1$line2$line3$city$state$pin”

$ Character is used as a separator to separate the values of line1, line2, line3, city, state and pin attributes.  The class supplies accessor methods for every instance field. All accessor methods return only String type value. Implement the Address class in java as per mentioned specification.

 

(b)

Considering the availability of the code of class Address of Q2(a) in this question, complete the implementation of the following class named ‘AddressList’ as per commented specification given below

class AddressList

{

public static int countAddressWithCity(Adress[] addressList, String city)

{

/*

This method returns the count of the addresses from addressList which have the city attribute equals to city parameter passed for this method. If the length of any passed argument is zero or value of any passed argument is null then it returns -1.

*/

}// End of method countAddressWithCity()

public static int countAddressWithPin(Adress[] addressList, String strP)

{

/*

This method returns the count of the addresses from addressList which have the pin attribute starting with strP parameter passed for this method. If the length of any passed argument is zero or value of any passed argument is null then it returns -1.

*/

}// End of method countAddressWithCity()

public static Address[] getAddressWithCity(Adress[] addressList, String city)

{

/*

This method returns all the addresses from addressList by storing them in String[] which have the city attribute equals to city parameter passed for this method. If the length of any passed argument is zero or value of any passed argument is null then it returns null.  If addressList does not contain any address with city attribute value equal to city parameter passed for this method even then it returns null.

*/

}// End of method getAddressWithCity()

public static Address[] getAddressWithPin(Adress[] addressList, String strP)

{

/*

This method returns all the addresses from addressList by storing them in String[] which have their pin  attribute starting with strP parameter passed for this method. If the length of any passed argument is zero or value of any passed argument is null then it returns null. If addressList does not contain any address whose pins  attribute value starts with strP parameter passed for this method even then it returns null.

*/

}// End of method getAddressWithCity()

}// End of class AddressList

[4+4+6+6=20M]

Q3. [Expected Time: 15 Mins]

(a)

Consider an abstract class named ‘Auto’ with instance fields as: # make : int and #price : double. The class provides parameterized constructor which receives the values for make and price of the car. The class supplies accessor and mutator methods for every instance field. Every mutator method in the class is only having method declaration not implementation. The Auto class has two concrete sub classes named ‘Maruti’ and ‘Honda’. Each of the subclass has an additional attribute as: # color: int (only three possible colors: 1 for white, 2 for blue and 3 for black). Each of the sub classes have their own parameterized constructors and the subclasses also supply a suitable toString() method which after concatenation returns the value(s) of instance fields with proper headings.

Write the implementations of classes Auto, Maruti and Honda in java as per above specification.

(b)

Write a driver class named ‘AutoTest’ for the ‘Auto’ class of Q3(a). This class performs the following tasks in order:

(i)                 Instantiates two instances of type Auto named auto1 and auto2 referring to Maruti and Honda type of objects respectively. [Assume any arbitrary values for attributes]

(ii)               Display the price of auto1 and auto2 (i.e. instances created above) on System.out.

(iii)             Print the details of auto1 and auto2 on System.out.

 

[10+5=15M]

Calculate your paper price
Pages (550 words)
Approximate price: -

Why Choose Us

Quality Papers

We value our clients. For this reason, we ensure that each paper is written carefully as per the instructions provided by the client. Our editing team also checks all the papers to ensure that they have been completed as per the expectations.

Professional Academic Writers

Over the years, our Acme Homework has managed to secure the most qualified, reliable and experienced team of writers. The company has also ensured continued training and development of the team members to ensure that it keep up with the rising Academic Trends.

Affordable Prices

Our prices are fairly priced in such a way that ensures affordability. Additionally, you can get a free price quotation by clicking on the "Place Order" button.

On-Time delivery

We pay strict attention on deadlines. For this reason, we ensure that all papers are submitted earlier, even before the deadline indicated by the customer. For this reason, the client can go through the work and review everything.

100% Originality

At Essay USA, all papers are plagiarism-free as they are written from scratch. We have taken strict measures to ensure that there is no similarity on all papers and that citations are included as per the standards set.

Customer Support 24/7

Our support team is readily available to provide any guidance/help on our platform at any time of the day/night. Feel free to contact us via the Chat window or support email: support@acmehomework.com.

Try it now!

Calculate the price of your order

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Essay USA has stood as the world’s leading custom essay writing services providers. Once you enter all the details in the order form under the place order button, the rest is up to us.

Essays

Essay Writing Services

At Essay USA, we prioritize on all aspects that bring about a good grade such as impeccable grammar, proper structure, zero-plagiarism and conformance to guidelines. Our experienced team of writers will help you completed your essays and other assignments.

Admissions

Admission and Business Papers

Be assured that you’ll definitely get accepted to the Master’s level program at any university once you enter all the details in the order form. We won’t leave you here; we will also help you secure a good position in your aspired workplace by creating an outstanding resume or portfolio once you place an order.

Editing

Editing and Proofreading

Our skilled editing and writing team will help you restructure you paper, paraphrase, correct grammar and replace plagiarized sections on your paper just on time. The service is geared toward eliminating any mistakes and rather enhancing better quality.

Coursework

Technical papers

We have writers in almost all fields including the most technical fields. You don’t have to worry about the complexity of your paper. Simply enter as much details as possible in the place order section.