Question

Can some please help me to answer these two questions. Write a program in Java create...

Can some please help me to answer these two questions. Write a program in Java

  1. create a class diagram fragment with two classes: User and Patient. Patient is a sub-class of User. User has a method getName(), which is both over-loaded and over-ridden in the subclass

  1. In Java write an abstract class called User. User has one abstract method called authenticate, which takes two string parameters. Write a concrete sub-class of User called Administrator with an implementation of the authenticate method. The authenticate method should just test that the two parameters are not null. Finally, write an interface called Printable, which includes one method called print. The Administrator class implements the Printable interface and prints the object (this.toString() ) to the command line.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
abstract class User {
    abstract boolean authenticate(String a, String b);
}

interface Printable {
    void print();
}

class Administrator extends User implements Printable {

    boolean authenticate(String a, String b) {
       return a != null && b != null;
    }

    public void print() {
        System.out.println(this.toString());
    }
}
Add a comment
Know the answer?
Add Answer to:
Can some please help me to answer these two questions. Write a program in Java create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help me to solve this problem with java language! write a program that runs a...

    Please help me to solve this problem with java language! write a program that runs a thread which prints a timestamp and then waits a second by doing the following: 1. Implement a class that implements the Runnable interface. (1 point) 2. Place the code for your task into the run method of your class. (6 points) a) To get the date and time, construct a Date object. b) To wait a second, use the sleep method of the Thread...

  • Can someone please help with this in JAVA? Write one application program by using the following...

    Can someone please help with this in JAVA? Write one application program by using the following requirements: 1) Exception handling 2) Inheritance a) At least one superclass or abstract superclass: this class needs to have data members, accessor, mutator, and toString methods b) At least one subclass: this class also needs to have data members, accessor, mutator, and toString methods c) At least one interface: this interface needs to have at least two abstract methods d) At least one method...

  • USING Java, create a program with the following: (I would like a different answer than the...

    USING Java, create a program with the following: (I would like a different answer than the answer on a similar question asked from someone else) 1-The first class is an abstract class called Weapon: a-Weapon has two different abstract methods: i-The first abstract method is void and is called attackType ii-The second abstract method is void and is called range b-Weapon has a constructor that accepts the weaponName c-Weapon also has a regular method that calculatesDamange and takes in attackType...

  • ISu a The paradox d I ata fields (or mputers. Program 3 Assume the existence of a class called Vo...

    ISu a The paradox d I ata fields (or mputers. Program 3 Assume the existence of a class called Voter which defines two instance variables: Add 10 user to the ArrayList. private String name; rivate char party: 'D'for Democrat or 'R' for Republican Assume that this class implements these two methods: public char getParty() public String tostring) // name and party affiliation Now assume you're in the main method in another class called VoterDriver. Write a Java statement that instantiates...

  • Answer the following: 1.        Create a Class Car with the following instance variables: model (String), Brand...

    Answer the following: 1.        Create a Class Car with the following instance variables: model (String), Brand (String), maxspeed (double) Note: use encapsulation (all variables are private). (3 Marks) 2.        Create a non-default constructor for Class Car which takes 3 parameters. (2 Marks) 3.        Create a get and set methods for instance variable model variable only. (2 Marks) 4.        Create PrintInfo() method which prints all three instance variables. (2 Marks) 5.        Create a subclass GasCar with instance variable TankSize (double).. (2...

  • Write ONE application program by using the following requirements: Using JAVA File input and outp...

    Write ONE application program by using the following requirements: Using JAVA File input and output Exception handling Inheritance At least one superclass or abstract superclass: this class needs to have data members, accessor, mutator, and toString methods At least one subclass: this class also needs to have data members, accessor, mutator, and toString methods At least one interface: this interface needs to have at least two abstract methods At least one method overloading At least one method overriding At least...

  • Create a Bitbucket private repository. Name it “CUS1156_Lab2”. Clone it in your local java Eclipse workspace....

    Create a Bitbucket private repository. Name it “CUS1156_Lab2”. Clone it in your local java Eclipse workspace. You will add the java files after you have completed them in Part 1 and Part 2 to this location. Part 1: Abstract classes From class, an abstract class represents some generic concept. Subclasses then provide their own specific implementations of any abstract methods of the abstract class. 1. Implement an abstract class called Shape it was discussed in the lecture. Include an abstract...

  • JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class...

    JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare (); } The prepare method will...

  • JAVA Problem:  Coffee do not use ArrayList or Case Design and implement a program that manages coffees....

    JAVA Problem:  Coffee do not use ArrayList or Case Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare ();...

  • java questions , help me and answer them please ! 6. Which of the following classes...

    java questions , help me and answer them please ! 6. Which of the following classes define a legal abstract class? 1: class A 2: abstract void unfinished 4: 1: public class abstract A 2: abstract void unfinished 1: class A 2: abstract void unfinished 3: 1: abstract class A 2: protected void unfinished 3: 1: abstract class A 2: abstract void unfinished 3: 1: class A 2: abstract int unfinished 3: 7. Suppose A is an interface. Can you...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT