MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
9th Edition
ISBN: 9780357505540
Author: Farrell; Joyce
Publisher: Cengage Learning US
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 1, Problem 1PE
Explanation of Solution
Class identifiers:
- Naming convention for class name is “Capitalize the first letter of each word”. For example: “ComputePerimeter”, “AngleCalc”, and “TestScore”.
Class Identifiers | a | b | c | ||
Legal | Conventional | Legal | Unconventional | Illegal | |
myClass | Yes | Yes, the starting letter of class identifier should be upper case in java | |||
void | Yes, the class identifier is illegal, since “void” is keyword | ||||
Golden Retriever | Yes, it is illegal to have space in class identifiers | ||||
invoice# | Yes, A java class identifier can contain only letters, digits, underscores, or dollar sign... |
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Is each of the following class identifiers (a) legal and conventional, (b) legal but unconventional, or (c) illegal?a. myClassb. voidc. Golden Retrieverd. invoice#e. 36542ZipCodef. Apartmentg. Fruith. 8888i. displayTotal()j. Accounts_Receivable
Create a python code with the following:• A Class called Player with four(4) attributes and two(2) methods:• String name, Char sex, int health, int power• Attack(), Defend()
• Print the lines:• "My character's name is <name>"• "<he/she> has <health> health and <power> power"• Use if statements for <he/she>• Print function Attack():• "<name> attacked with <power> power"
PS: Please answer number 1 and 2 as they are related everything altogether. Make sure the code delivers expected successful output.
1. Create a Java class named Package that contains the following:a. Package should have three private instance variables of type double named length, width, andheight.b. Package should have one private instance variable of the type Scanner named input, initializedto System.in.c. No-args (explicit default) public constructor, which initializes all three double instance variables to1.0.d. Initial (parameterized) public constructor, which defines three parameters of type double,named length, width, and height, which are used to initialize the instance variables of same name.e. Public copy constructor, with a parameter of type Package, used to duplicate anexisting Package object.f. Three public void methods named inputLength, inputWidth, and inputHeight. Each methodwill prompt the user for the appropriate property, and input a double value usingthe Scanner…
Chapter 1 Solutions
MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
Ch. 1 - Prob. 1RQCh. 1 - Prob. 2RQCh. 1 - Prob. 3RQCh. 1 - Prob. 4RQCh. 1 - Prob. 5RQCh. 1 - Prob. 6RQCh. 1 - Prob. 7RQCh. 1 - Prob. 8RQCh. 1 - Prob. 9RQCh. 1 - Prob. 10RQ
Ch. 1 - Prob. 11RQCh. 1 - Prob. 12RQCh. 1 - Prob. 13RQCh. 1 - Prob. 14RQCh. 1 - Prob. 15RQCh. 1 - Prob. 16RQCh. 1 - Prob. 17RQCh. 1 - Prob. 18RQCh. 1 - Prob. 19RQCh. 1 - Prob. 20RQCh. 1 - Prob. 1PECh. 1 - Prob. 2PECh. 1 - Prob. 3PECh. 1 - Prob. 4PECh. 1 - Prob. 5PECh. 1 - Prob. 6PECh. 1 - Prob. 7PECh. 1 - Prob. 8PECh. 1 - Prob. 9PECh. 1 - Prob. 10PECh. 1 - Prob. 11PECh. 1 - Prob. 12PECh. 1 - Prob. 1DECh. 1 - Prob. 1GZCh. 1 - Prob. 1CPCh. 1 - Prob. 2CP
Knowledge Booster
Similar questions
- Consider the following class: public class IdentifyMyParts { public static int x = 7; public int y = 3; } 1. 1. What are the class variables? 2. What are the instance variables?arrow_forwardIn the following code, which is the superclass? //A class to represent secretaries. public class Secretary extends Employee { public void takeDictation(String text) { System.out.printlin("Dictating text: " + text); } }arrow_forwardGiven the following class, what sets of statements would have the end result of the myUser instance having the username as testuser and the password as testpassword and then outputting the username and password? public class User { private String userName; private String password; public User(String userName, String password) { this.userName = userName; this.password = password; } public String getUserName() { return userName; } public String getPassword() { return password; } public void setUserName(String userName) { this.userName = userName; } public void setPassword(String password) { this.password = password; } } 1- User myUser = new User("testuser","testpassword"); System.out.println("User: " + myUser.username); System.out.println("Password: " + myUser.password); 2- User myUser = new User("testuser","testpassword"); System.out.println("User: " + myUser.username()); System.out.println("Password: " + myUser.password());…arrow_forward
- I need help with creating a Java program described in the image below: CourseInformation.java: import java.util.Scanner; public class CourseInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Course myCourse = new Course(); OfferedCourse myOfferedCourse = new OfferedCourse(); String courseNumber, courseTitle; String oCourseNumber, oCourseTitle, instructorName, location, classTime; courseNumber = scnr.nextLine(); courseTitle = scnr.nextLine(); oCourseNumber = scnr.nextLine(); oCourseTitle = scnr.nextLine(); instructorName = scnr.nextLine(); location = scnr.nextLine(); classTime = scnr.nextLine(); myCourse.setCourseNumber(courseNumber); myCourse.setCourseTitle(courseTitle); myCourse.printInfo(); myOfferedCourse.setCourseNumber(oCourseNumber); myOfferedCourse.setCourseTitle(oCourseTitle); myOfferedCourse.setInstructorName(instructorName);…arrow_forwardPS: Please say the logic behind it. Thank you! 1. Create a java class Vehicle.a. The class should have two fields:i. no_of_seats and no_of_wheels.b. Create two objectsi. Motorcycle and Car for this class.c. Your output should show the descriptions for Car and Motorcyclearrow_forwardPlease teach me how to fix an error from my JAVA source code. I have set up the source code with class name "ProductionWorker" and there were a error occured on second page of sceenshot where it is highlighted. //import the file import java.util.*; //create the class class Employee { //create the variable private String emp_num; //create the date variable private Date hiring_date; // default constructor public Employee() { //assign the emp num. this.emp_num = "000-A"; //assign the Date this.hiring_date = new Date(); } // constructor parameter public Employee(String emp_num, Date hiring_date) { this.emp_num = emp_num; this.hiring_date = hiring_date; } // getter method public String getEmployeeNumber() { return this.emp_num; } // call the gethiringdate function public Date gethiringDate() { // return the date return this.hiring_date; } // setter method public void setEmployeeNumber(String emp_num) { //set the emp num. this.emp_num = emp_num; } //set the hiring date public void…arrow_forward
- The three java files (source code) pasted below associated with this question. Any help will be greatly appreciated!! QUESTION (using Eclipse and default Junit package that came with it): Create a Junit 4 test case for the Hourly class. Your test should use these methods from class org.junit.Assert: assertEquals to test the getJob() method assertEquals to test the getPayRate() method assertTrue to test the hours attribute Admin.java package ch44extra; import java.time.LocalDate; public class Admin extends Person { private String dept; private String office; private double salary; //private double budget;removed to simplify class public Admin(String name, LocalDate date, int id, String dept, String office, double salary) { super(name, date, id); this.dept = dept; this.office = office; this.salary = salary; } public Admin() { super(); // TODO Auto-generated constructor stub } public String getDept() { return dept; } public void setDept(String dept) { this.dept = dept; }…arrow_forwardGiven the following set of classes, what would need to be fixed to output the customer's password? public class Customer { private String userName; private String password; public Customer(String userName, String password) { this.userName = userName; this.password = password; } public void setPassword(String password) { this.password = password; } public String getPassword() { return password; } public void setUserName(String userName) { this.userName = userName; } public String getUserName() { return userName; } } class CustomerTest { public static void main(String[] args) { Customer cust = new Customer("user","pass"); cust.setPassword("Java"); outputPassword(); } public static void outputPassword(Customer cust){ System.out.println("Password: " + cust.getPassword()); } } 1- The cust should be declared at the class level to be accessed in the outputPassword() method. 2- The cust should be…arrow_forwardJava ...... Two files are required, a data class named Book and an executable class named TestBook. Class Book has instance data members (all private) String title, String author, int pages, double price. has a public static int variable named numBooks with an initial value of zero. has a parameterized constructor that will be used to make a Book object and assign values to its data members, and increment numBooks. has a no-arg constructor that increments numBooks. has getters and setters for all instance data members. has a toString() method that returns a string displaying the state of a Book instance. Use the numBooks variable to report the number of books instantiated. Class TestBook This class needs a main method and two more methods. In main: create an array capable of holding six Book objects. use the parameterized constructor to specify the data in the first four elements of this array use the no-arg constructor to create the two remaining books in the array.…arrow_forward
- Given Enum.java, Data.java (which may have overlapping variables), and the following start of Player.java :public enum Position { Attacker, Midfield, Defender, Goalie} public class Team { //Variables private Player[] players; private int squadSize; // Two Constructors public Team(Player[] players) { this.players = players; this.size = players.length; } public Team() { this.players = new Player[4]; this.size = 0; } }How would I go about creating the given method named 'Play'?arrow_forwardI'm writing a text adventure java game and I'm having trouble calling my enemy class this is what I wrote in the enemy class: package package01; import java.util.Random; public class Enemy { private String name; private int hp; private int attackPower; public Enemy(String name, int hp, int attackPower) { this.name = name; this.hp = hp; this.attackPower = attackPower;} public static Enemy getRandomEnemy() { Random rand = new Random(); // Generate random attributes for the enemy String[] names = {"Zombie", "Spider", "Assassin"}; String name = names[rand.nextInt(names.length)]; int hp = rand.nextInt(100) + 1; // Random HP between 1 and 100 int attackPower = rand.nextInt(10) + 1; // Random attack power between 1 and 10 // Return a new enemy with the random attributes return new Enemy(name, hp, attackPower); but when I try to run it in the story class I keep getting errors how can i fix thisarrow_forwardRecall the Rectangle and Cube classes discussed earlier, as shown in Figure 10-18. a) Is the following statement legal or illegal? If it is illegal, why?Rectangle r = new Cube(10, 12, 5);b) If you determined that the statement in part a is legal, are the following statementslegal or illegal? (Indicate legal or illegal for each statement.)System.out.println(r.getLength());System.out.println(r.getWidth());System.out.println(r.getHeight());System.out.println(r.getSurfaceArea());c) Is the following statement legal or illegal? If it is illegal, why?Cube c = new Rectangle(10, 12);arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT