Knowee
Questions
Features
Study Tools

Given the following class, what sets of statements would have the end result of the myCustomer instance having the customername as AB1002 password as test as testpassword and then outputting the customername and password?public class Customer { private String customerName; private String password; public Customer(String customerName, String password) { this.customerName = customerName; this.password = password; } public String getCustomerName() { return customerName; } public String getPassword() { return password; } public void setCustomerName(String customerName) { this.customerName = customerName; } public void setPassword(String password) { this.password = password; }}Customer myCustomer = new Customer("AB1002","testpassword");System.out.println("Customer: " + myCustomer.customername());System.out.println("Password: " + myCustomer.password());Customer myCustomer = new Customer();myCustomer.setCustomerName("AB1002");myCustomer.setPassword("testpassword");System.out.println("Customer: " + myCustomer.getCustomerName());System.out.println("Password: " + myCustomer.getPassword());Customer myCustomer = new Customer("AB1002","testpassword");System.out.println("Customer: " + myCustomer.getCustomerName());System.out.println("Password: " + myCustomer.getPassword());Customer myCustomer = new Customer("AB1002","testpassword");System.out.println("Customer: " + myCustomer.customername);System.out.println("Password: " + myCustome

Question

Given the following class, what sets of statements would have the end result of the myCustomer instance having the customername as AB1002 password as test as testpassword and then outputting the customername and password?public class Customer { private String customerName; private String password; public Customer(String customerName, String password) { this.customerName = customerName; this.password = password; } public String getCustomerName() { return customerName; } public String getPassword() { return password; } public void setCustomerName(String customerName) { this.customerName = customerName; } public void setPassword(String password) { this.password = password; }}Customer myCustomer = new Customer("AB1002","testpassword");System.out.println("Customer: " + myCustomer.customername());System.out.println("Password: " + myCustomer.password());Customer myCustomer = new Customer();myCustomer.setCustomerName("AB1002");myCustomer.setPassword("testpassword");System.out.println("Customer: " + myCustomer.getCustomerName());System.out.println("Password: " + myCustomer.getPassword());Customer myCustomer = new Customer("AB1002","testpassword");System.out.println("Customer: " + myCustomer.getCustomerName());System.out.println("Password: " + myCustomer.getPassword());Customer myCustomer = new Customer("AB1002","testpassword");System.out.println("Customer: " + myCustomer.customername);System.out.println("Password: " + myCustome

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct set of statements to create an instance of the Customer class with the customerName as "AB1002" and password as "testpassword", and then output the customerName and password would be:

Customer myCustomer = new Customer("AB1002","testpassword");
System.out.println("Customer: " + myCustomer.getCustomerName());
System.out.println("Password: " + myCustomer.getPassword());

Here's the step by step explanation:

  1. Customer myCustomer = new Customer("AB1002","testpassword"); - This line creates a new instance of the Customer class, calling the constructor and passing in "AB1002" as the customerName and "testpassword" as the password.

  2. System.out.println("Customer: " + myCustomer.getCustomerName()); - This line outputs the customerName of the myCustomer instance. It calls the getCustomerName() method on myCustomer, which returns the customerName, and then concatenates it with the string "Customer: " to output it.

  3. System.out.println("Password: " + myCustomer.getPassword()); - This line outputs the password of the myCustomer instance. It calls the getPassword() method on myCustomer, which returns the password, and then concatenates it with the string "Password: " to output it.

This problem has been solved

Similar Questions

Demonstrate ability to set and change the values of object properties.Given the following class, what sets of statements would have the end result of the myCustomer instance having the username as XC1001 and the password as testpass?public class Customer { private String customerCode; private String password; public Customer(String customerCode, String password) { this.customerCode = customerCode; this.password = password; } public String getCustomerCode() { return customerCode; } public String getPassword() { return password; } public void setCustomerCode(String customerCode) { this.customerCode = customerCode; } public void setPassword(String password) { this.password = password; }}a.)Customer myCustomer = newCustomer("testpass","XC1001");b.)Customer myCustomer = new Customer("username","password");myCustomer.setCustomerCode("XC1001");myCustomer.setPassword("testpass");c.)Customer myCustomer = newCustomer("XC1001","testpass");myCustomer.setCustomerCode("user");myCustomer.setPassword("pass");d.)Customer myCustomer = new Customer();myCustomer.setCustomerCode("XC1001");myCustomer.setPassword("testpass");

Given the following set of classes: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 testAcct = new Customer("user","pass"); testAcct.setPassword("Java"); System.out.println(testAcct.toString()); }}What does the toString() method need to look like to result in the following output:UserName: userPassword: Javaa.)public String toString() { String state = "UserName: " + userName + "\n"; state += "Password: " + password + "\n"; return state;}b.)public String toString() { String state = "UserName: " + userName + "\n"; state += "Password: " + password + "\n"; return password;}c.)public String toString() { String state = "UserName: " + userName + "\n"; state = "Password: " + password + "\n"; return state;}d.)public String toString() { String state = "username: " + userName + "\n"; state += "password: " + password + "\n"; return state;}

Given the following set of classes, what needs to be fixed to make the program produce the output Name: Java?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 c1 = new Customer("user","pass"); c1.setUserName("Java"); outputName(); } public static void outputName(){ System.out.println("Name: " + c1.getUserName()); }} a.)The c1 should be returned as a return value from outputName().b.)The c1 should be passed into the outputName() method as a parameter.c.)The instance c1 is not in scope in the method outputName(). The instance c1 needs to be declared in outputName()d.)The instance c1 is not in scope in the method outputName(). The c1 should be globally in CustomerTest to be accessed in the outputName() method.

Which of the following methods can be added to the UserAccount class in the tutorial to access the password?a.)public void setPassword(int password) { this.password = password;}b.)public int getPassword() { return password;}c.)public void setPassword(String password) { this.password = password;}d.)public String getPassword() { return password;}

Which of the following methods can be added to the UserAccount class in the tutorial to change the password?a.)public void setPassword(String password) { this.password = password;}b.)public int getPassword() { return password;}c.)public void setPassword(int password) { this.password = password;}d.)public String getPassword() { return password;}

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.