Question

In: Computer Science

In the following Java class, what would the following createFromString(String string) and saveToString() methods return? /**...

In the following Java class, what would the following createFromString(String string) and saveToString() methods return?

/**
* This class represents a DVD player to be rented.
*
* @author Franklin University
* @version 2.0
*/
public class DVDPlayer extends AbstractItem
{

/**
* Constructor for objects of class DVDPlayer.
*/
public DVDPlayer()
{
// No code needed
}

/**
* Creates a DVDPlayer from a string in the format
* id:desc:weeklyRate:rented
* @param string The string
* @return the new DVDPlayer
*/
public static DVDPlayer createFromString(String string) {
return null;
}

@Override
public String saveToString() {
return null;
}
}

Solutions

Expert Solution

In the above java class the above functions createFromString(String string) and saveToString() both return "null".

Even though the return type for both functions are class type and string respectively however, they both return null values irrespective of the return type null values doesn't depend on them i.e., null is returned for all the inputs.

Hence so here I attach to clarify any further doubts the implemented code and outputs respectively.PS I've used some example strings for ease.

Thank you.


Related Solutions

Code in Java Given the LinkedList class that is shown below Add the following methods: add(String...
Code in Java Given the LinkedList class that is shown below Add the following methods: add(String new_word): Adds a linkedlist item at the end of the linkedlist print(): Prints all the words inside of the linkedlist length(): Returns an int with the length of items in the linkedlist remove(int index): removes item at specified index itemAt(int index): returns LinkedList item at the index in the linkedlist public class MyLinkedList { private String name; private MyLinkedList next; public MyLinkedList(String n) {...
Write the following methods in a Java project: a) A Java method to determine and return...
Write the following methods in a Java project: a) A Java method to determine and return the sum of first three numbers, where three numbers are received as parameters. b) A Java method to determine and return the highest of N integers. The number of integers is received as a parameter. The method should prompt the user to enter the N numbers, then it return the highest. c) A Java method to determine and return an appropriate value indicating if...
java programing Q: Given the following class: public class Student { private String firstName; private String...
java programing Q: Given the following class: public class Student { private String firstName; private String lastName; private int age; private University university; public Student(String firstName, String lastName, int age, University university) { this.firstName = fisrtName; this.lastName = lastName; this.age = age; this.university = university; } public String getFirstName(){ return firstName; } public String getLastName(){ return lastName; } public int getAge(){ return age; } public University getUniversity(){ return university; } public String toString() { return "\nFirst name:" + firstName +...
In Java, Here is a basic Name class. class Name { private String first; private String...
In Java, Here is a basic Name class. class Name { private String first; private String last; public Name(String first, String last) { this.first = first; this.last = last; } public boolean equals(Name other) { return this.first.equals(other.first) && this.last.equals(other.last); } } Assume we have a program (in another file) that uses this class. As part of the program, we need to write a method with the following header: public static boolean exists(Name[] names, int numNames, Name name) The goal of...
Java... Design a Payroll class with the following fields: • name: a String containing the employee's...
Java... Design a Payroll class with the following fields: • name: a String containing the employee's name • idNumber: an int representing the employee's ID number • rate: a double containing the employee's hourly pay rate • hours: an int representing the number of hours this employee has worked The class should also have the following methods: • Constructor: takes the employee's name and ID number as arguments • Accessors: allow access to all of the fields of the Payroll...
In Java: Design a class that checks if a String is made of tokens of the...
In Java: Design a class that checks if a String is made of tokens of the same data type (for this, you may only consider four data types: boolean, int, double, or char). This class has two instance variables: the String of data and its delimiter. Other than the constructor, you should include a method, checkTokens, that takes one parameter, representing the data type expected (for example, 0 could represent boolean, 1 could represent int, 2 could represent double, and...
Use Java programming to implement the following: Implement the following methods in the UnorderedList class for...
Use Java programming to implement the following: Implement the following methods in the UnorderedList class for managing a singly linked list that cannot contain duplicates. Default constructor Create an empty list i.e., head is null. boolean insert(int data) Insert the given data into the end of the list. If the insertion is successful, the function returns true; otherwise, returns false. boolean delete(int data) Delete the node that contains the given data from the list. If the deletion is successful, the...
Java RECURSIVE methods: => intersection(String s1, String s2): takes two strings and returns the string consisting...
Java RECURSIVE methods: => intersection(String s1, String s2): takes two strings and returns the string consisting of all letters that appear in both s1 and s2. => union(String s1, String s2): takes two strings and returns the string consisting of all letters that appear in either s1 or s2. =>difference(String s1, String s2): takes two strings and returns the string consisting of all letters that appear only in s1.
What would the pseudocode look like for this UML class diagram? Class - oranges: String -...
What would the pseudocode look like for this UML class diagram? Class - oranges: String - bananas: String - grapes: String - apples: String + Class(String bananas, String grapes, String apples) + oranges( ): void + isValidGrapes( ): boolean + isValidApples( ): boolean + getOranges( ): String + getBananas( ): String + setBananas(String bananas): void + getGrapes( ): String + setGrapes(String grapes): void + getApples( ): String + setApples(String apples): void
java code Add the following methods to the LinkedQueue class, and create a test driver for...
java code Add the following methods to the LinkedQueue class, and create a test driver for each to show that they work correctly. In order to practice your linked list cod- ing skills, code each of these methods by accessing the internal variables of the LinkedQueue, not by calling the previously de?ined public methods of the class. String toString() creates and returns a string that correctly represents the current queue. Such a method could prove useful for testing and debugging...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT