Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 13.7, Problem 13.7.1CP
Can a class invoke the super.clone() when implementing the clone() method if the class does not implement the java.lang.Cloneable? Does the Date class implement Cloneable?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create a Java program that will store 10 student objects in an ArrayList, ArrayList<Student>. A student object consists of the following fields:
int rollno
String name
String address
Implement two comparator classes to sort student objects by name and by rollno (roll number). Implement your own selection sort method.
*Does the program below meet the above requirements? Can the program be made anymore effecient? Is there any improvements that could be made? (modularity, organization, etc..) If so what would they be/look like? I could also use some help with comments to explain the programs functionality.*
Please and thank you!
Source code:
import java.util.ArrayList;import java.util.Comparator;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JTextArea;
class Student { int rollno; String name; String address; public Student(int roll, String name, String add) { super(); this.rollno = roll; this.name = name;…
import java.util.Scanner; public class LabProgram {
public static Roster getInput(){ /* Reads course title, creates a roster object with the input title. Note that */ /* the course title might have spaces as in "COP 3804" (i.e. use nextLine) */ /* reads input student information one by one, creates a student object */ /* with each input student and adds the student object to the roster object */ /* the input is formatted as in the sample input and is terminated with a "q" */ /* returns the created roster */ /* Type your code here */ } public static void main(String[] args) {
Roster course = getInput(); course.display(); course.dislayScores(); }}
public class Student {
String id; int score;
public Student(String id, int score) { /* Student Employee */ /* Type your code here */ }
public String getID() { /* returns student's id */…
Please dont copy and paste and give proper explanation.
Suppose that a Java implementer is required to write a method which takes in as parameter a List of objects belonging to a Person class.
Person has several subclasses including Employee. The method is supposed to return another List which consists of just the Employee objects from the original list. Describe two different ways of accomplishing this in Java.
Chapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 13.2 - Prob. 13.2.1CPCh. 13.2 - The getArea() and getPerimeter() methods may be...Ch. 13.2 - True or false? a.An abstract class can be used...Ch. 13.3 - Prob. 13.3.1CPCh. 13.3 - Prob. 13.3.2CPCh. 13.3 - Prob. 13.3.3CPCh. 13.3 - What is wrong in the following code? (Note the...Ch. 13.3 - What is wrong in the following code? public class...Ch. 13.4 - Can you create a Calendar object using the...Ch. 13.4 - Prob. 13.4.2CP
Ch. 13.4 - How do you create a Calendar object for the...Ch. 13.4 - For a Calendar object c, how do you get its year,...Ch. 13.5 - Prob. 13.5.1CPCh. 13.5 - Prob. 13.5.2CPCh. 13.5 - Prob. 13.5.3CPCh. 13.5 - Prob. 13.5.4CPCh. 13.6 - Prob. 13.6.1CPCh. 13.6 - Prob. 13.6.2CPCh. 13.6 - Can the following code be compiled? Why? Integer...Ch. 13.6 - Prob. 13.6.4CPCh. 13.6 - What is wrong in the following code? public class...Ch. 13.6 - Prob. 13.6.6CPCh. 13.6 - Listing 13.5 has an error. If you add list.add...Ch. 13.7 - Can a class invoke the super.clone() when...Ch. 13.7 - Prob. 13.7.2CPCh. 13.7 - Show the output of the following code:...Ch. 13.7 - Prob. 13.7.4CPCh. 13.7 - What is wrong in the following code? public class...Ch. 13.7 - Show the output of the following code: public...Ch. 13.8 - Prob. 13.8.1CPCh. 13.8 - Prob. 13.8.2CPCh. 13.8 - Prob. 13.8.3CPCh. 13.9 - Show the output of the following code: Rational r1...Ch. 13.9 - Prob. 13.9.2CPCh. 13.9 - Prob. 13.9.3CPCh. 13.9 - Simplify the code in lines 8285 in Listing 13.13...Ch. 13.9 - Prob. 13.9.5CPCh. 13.9 - The preceding question shows a bug in the toString...Ch. 13.10 - Describe class-design guidelines.Ch. 13 - (Triangle class) Design a new Triangle class that...Ch. 13 - (Shuffle ArrayList) Write the following method...Ch. 13 - (Sort ArrayList) Write the following method that...Ch. 13 - (Display calendars) Rewrite the PrintCalendar...Ch. 13 - (Enable GeometricObject comparable) Modify the...Ch. 13 - Prob. 13.6PECh. 13 - (The Colorable interface) Design an interface...Ch. 13 - (Revise the MyStack class) Rewrite the MyStack...Ch. 13 - Prob. 13.9PECh. 13 - Prob. 13.10PECh. 13 - (The Octagon class) Write a class named Octagon...Ch. 13 - Prob. 13.12PECh. 13 - Prob. 13.13PECh. 13 - (Demonstrate the benefits of encapsulation)...Ch. 13 - Prob. 13.15PECh. 13 - (Math: The Complex class) A complex number is a...Ch. 13 - (Use the Rational class) Write a program that...Ch. 13 - (Convert decimals to fractious) Write a program...Ch. 13 - (Algebra: solve quadratic equations) Rewrite...Ch. 13 - (Algebra: vertex form equations) The equation of a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Consider the adage Never ask a question for which you do not want the answer. a. Is following that adage ethica...
Experiencing MIS
Figure 1.5.7 shows a slope field and typical solution curves for the equation y=xy. (a) Show that every solutio...
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Describe two properties that each candidate key must satisfy.
Modern Database Management
Method intToFloat, which takes integer argument number and returns a float.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Write an if-else statement that outputs the word Warning provided that either the value of the variable tempera...
Problem Solving with C++ (9th Edition)
Write out the header of a for-each loop to process an ArrayList called tracks. Don't worry about the loop's bod...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Describe how Object.clone could be modified to use a @Cloneable annotation instead of the Cloneable marker interface.JAVAarrow_forwardMake a recursive method for factoring an integer n. First, find a factor f, then recursively factor n / f. This assignment needs a resource class and a driver class; these two classes will need to be in two separate files. The resource class will contain all of the methods and the driver class only needs to call the methods. The driver class needs to have only 5 lines of code. The code needs to be written in Java.arrow_forwardWrite a Java class that would match a string. The class has method match with String as a return type. It accepts two inputs: the phrase/sentence string (text) and the pattern string (word). This method finds the first (or all) instances of the pattern in the text and changes that word in all uppercase and return the new phrase. Method countOccurence accepts a phrase/sentence and a pattern string and returns its number of occurrences. Add a main method that will allow the user to input the phrase/sentence and pattern. Call method match and countOccurence. See test case below. Sample Input: Text string: You will always have my love, my love, for the love I love is as lovely as love itself. Pattern string: love Output: New text: You will always have my LOVE, my LOVE, for the LOVE I LOVE is as lovely as LOVE itself. Number of occurrence: 5 For example: Input Result You will always have my love, my love, for the love I love is as lovely as love itself. love New text: You…arrow_forward
- *using java* Create a class AnimalCreate a class Cat, and a class Dog, and a class Bearded Dragon which extend Animal. Add to your Animal class: Member: name Methods: Public Animal(String name) //constructor public void makesSound()with the implementation printing out a generic animal sound. Next, override (add) the makesSound()method to your Cat and Dog class, with the implementation specific to each animal (i.e, cat says purr..). Do not override the makesSound() for your Dragon (bearded dragons don’t make sounds!)Note, you’ll also need a constructor in each of your subclasses which calls super(name) to initialize the common ‘name’ member of Animal. --- Next (in your test harness) create a List of different Animals ( a couple cats, a dog, a dragon... ) and add these Animals to your list. Iterate through your list & call makeSound on each. ( you should observe the implementation of the makeSound() method called will be: cat -> from Cat class, dog-> from Dog class,…arrow_forward1. Modify the method beginsWithVowel. Use a different way to implement the method (try method indexOf() from the String class). 2. Modify the driver class to iteratively ask the user to enter a sentence, and then translate the sentence, until the user decides to quit the program. import java.util.Scanner;public class Translator { //instance variables //constructors //methods public static String translate(String sentence)// My name is Patrick Casseus { String result = ""; sentence = sentence.toLowerCase(); Scanner scan = new Scanner(sentence); while(scan.hasNext()) { result = result += translateWord(scan.next()) + " "; } return result; } private static String translateWord(String word) { String result = ""; if(startWithVowel(word)) result = word + "yay"; else if(startWithBlend(word)) // chair -> air + ch + ay result = word.substring(2) +…arrow_forwardCreate a Java class called Student with attributes name, age, and grade. Implement a parameterized constructor to initialize these attributes. Then, create an array of Student objects, populate it, and print the details of all students.arrow_forward
- Write a Java class Student inherited from Person class. Your class must have the following features: Student - major: String + Student() + Student(name: String, id: int, major: String) + getMajor(): String + Override toString() method: you have to return needed data Fields values. Note: major data members can take only CS for Computer Science, CIS for Computer and Information Systems, CPE for Computer Engineering, SE for Software Engineering, and NES for Network Engineering and Security.arrow_forwardClass Die java.lang.Objectextended by Diepublic class Dieextends java.lang.ObjectDie - an n-sided die with given integer values. The given integer values are returned via nextRoll() with uniform probability., Constructor SummaryDie() Creates a new Die instance with the default values: 1, 2, 3, 4, 5, 6.Die(int[] outcomes) Creates a new Die instance with the given integer outcomes.Die(int sides, int min) Creates a new Die with a given number of sides and an incremental sequence of values beginning with a given minimum value.Method Summaryint nextRoll() nextRoll - return one of the die values at random.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitConstructor DetailDie public Die(int[] outcomes)Creates a new Die instance with the given integer outcomes.Parameters:outcomes - an int[] value - an array of the integer values for each side of the die.Die public Die(int sides,int min)Creates a new Die with…arrow_forwardIn this java assignment, we will be creating a paystub for an employee using classes, files, getters, and setters. Each file should only have one class and the class should share the same name as the file. We are going to implement the following classes: Employee - This class represent the employee. It needs the following fields exposed via getters and setters: Employee ID (hard code it to 1) First name, last name, middle initial Address, city, zip Phone, email Hourly rate PayPeriod - This class represents an employee's payment information. An employee will eventually have more than one pay period. It needs the following fields exposed via getters and setters: Pay period Id (hard code to 123456) Employee Id Start date, end date Number of hours PayrollManager - This class provides the functionality we need to compute and display the payroll. It should implement the following methods: double CalculateGrossPay (Employee, PayPeriod) - this should return the total gross for the…arrow_forward
- Implement the copy assignment operator= for the StringVar class using the options given on the right side window. Place the code into the left side using the arrows. It is possible to get the test case correct but not complete NOTE: Be careful! There are decoys! The this pointer is used extensively.. Assume that StringVar.h has the following declaration: #include <iostream> class StringVar {public:StringVar() : max_length(20) { // Default constructor size is 20value = new char[max_length+1];value[0] = '\0';}StringVar(int size); // Takes an int for sizeStringVar(const char cstr[]); // Takes a c-string and copies itStringVar(const StringVar& strObj); // Copy Constructor~StringVar(); // Destructorint size() const { return max_length; } // Access capacityconst char* c_str() const { return value; } // Access valueint length() const { return strlen(value); } // Access lengthStringVar& operator= (const StringVar& rightObj);std::istream& operator>>…arrow_forwardGiven a class Square with an instance variable width, provide a recursive getArea method. Construct a square whose width is one less than the original and call its getArea method. Make a resource class that contains all of the methods and make a driver class in a separate file, and the driver class only needs to call those methods. The driver class needs to have only 5 lines of code. The code will need to be written in Java. Please help me with exactly what I asked for helparrow_forwardJAVA Program ASAP Please modify this program and take out the main method from the program so it passes the test cases in Hypergrade. I have provided the failed test cases. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;import java.util.InputMismatchException;import java.util.Scanner;public class FileSorting { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { System.out.println("Please enter the file name or type QUIT to exit:"); String fileName = scanner.nextLine(); if (fileName.equalsIgnoreCase("QUIT")) { break; } try { ArrayList<String> lines = readFile(fileName); if (lines.isEmpty()) { System.out.println("File " + fileName + " is empty."); } else { performSorting(lines);…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License