Questions
URGENT!!! DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps:...

URGENT!!!

DO THIS PROGRAM IN JAVA

Write a complete Java console based program following these steps:

1. Write an abstract Java class called Shape which has only one abstract method named getArea();

2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape.

3. Write the driver code tat tests the classes and methods you write above.

In: Computer Science

researchers were interested in the effects of cannibis and ecstacy on abstract thinking.Participants were given a...

researchers were interested in the effects of cannibis and ecstacy on abstract thinking.Participants were given a task that required them to solve problems/tasks using abstract thinking.Researchers also included a group of nonusers. Base on the scenario, identify the Idependent variable and the dependent variable. Is the IV a quasi or experimental?. what is the research question.

In: Civil Engineering

Which java collection have you used the most? and why? What does static mean in Java...

Which java collection have you used the most? and why?

What does static mean in Java and when should you use it? (Both static variable and static method)

What does abstract keyword mean in java and when should you use? (Both abstract class and method)

In: Computer Science

Java Program Make an interface called interface1 that has tow data fields- default_length=1 and Pi=3.14 Make...

Java Program

Make an interface called interface1 that has tow data fields- default_length=1 and Pi=3.14

Make a second interface called interface2 that has one method: double getPerimeter(),

Make an abstract class GeometricObject that implements the 2 interfaces. And make one method getArea as an abstract method.

Make a subclass of GeometricObject called Square. The square class will inherit the superclass methods and implements the required abstract methods.

Make a subclass of GeometricObject called Triangle. (This is an equilateral triangle.) Triangle class will inherit the superclass methods and implements the required abstract methods.

In another class called test,using polymorphism call, declare 6 objects. The objects should be enclosed in an ArrayList of GeometricObject.

GeometricObject obj1=new Square(2);

Geometric Object obj2= new Triangle(4);

ArrayList<GeometricObject> arr=new ArrayList();

Write a for loop to extract the objects and print out their data.

In: Computer Science

symposium abstract on bacteria

symposium abstract on bacteria

In: Biology

Mention 4 major categories of the international business environment. Mention and explain each of them.

Mention 4 major categories of the international business environment. Mention and explain each of them.

In: Operations Management

Q: Think of a material and mention at least one of its properties that possibly requires...

Q: Think of a material and mention at least one of its properties that possibly requires involvement in specific application and can be enhanced by the use if nanotechnology. Mention the application.

Q: Mention atleast one specific discipline involved in the implementation of nanotechnology and explain its possible contribution to nanomaterials development.

In: Other

1.Describe the cost per order system and mention two examples of companies that they use this...

1.Describe the cost per order system and mention two examples of companies that
they use this system.
2. Describe the cost per process system and mention two examples of companies that
they use this system.
3. Define what is the activity-based accounting system. Mention what they are
the companies that benefit from using this system and why.
4. Mention the importance of the analysis of variances in the cost system
standard. List and explain which are the variances that must be analyzed
when a product is manufactured or a service is provided.

In: Accounting

The purpose of creating an abstract class is to model an abstract situation. Example: You work...

The purpose of creating an abstract class is to model an abstract situation.

Example:

You work for a company that has different types of customers: domestic, international, business partners, individuals, and so on. It well may be useful for you to "abstract out" all the information that is common to all of your customers, such as name, customer number, order history, etc., but also keep track of the information that is specific to different classes of customer. For example, you may want to keep track of additional information for international customers so that you can handle exchange rates and customs-related activities, or you may want to keep track of additional tax-, company-, and department-related information for business customers.

Modeling all these customers as one abstract class ("Customer") from which many specialized customer classes derive or inherit ("InternationalCustomer," "BusinessCustomer," etc.) will allow you to define all of that information your customers have in common and put it in the "Customer" class, and when you derive your specialized customer classes from the abstract Customer class you will be able to reuse all of those abstract data/methods.This approach reduces the coding you have to do which, in turn, reduces the probability of errors you will make. It also allows you, as a programmer, to reduce the cost of producing and maintaining the program.

In this assignment, you will analyze Java™ code that declares one abstract class and derives three concrete classes from that one abstract class. You will read through the code and predict the output of the program.

Read through the linked Java™ code carefully.

Predict the result of running the Java™ code. Write your prediction into a Microsoft® Word document, focusing specifically on what text you think will appear on the console after running the Java™ code.

In the same Word document, answer the following question:

  • Why would a programmer choose to define a method in an abstract class, such as the Animal constructor method or the getName() method in the linked code example, as opposed to defining a method as abstract, such as the makeSound() method in the linked example?

CODE:

/**********************************************************************

*           Program:          PRG/421 Week 1 Analyze Assignment

*           Purpose:           Analyze the coding for an abstract class

*                                   and two derived classes, including overriding methods

*           Programmer:     Iam A. Student

*           Class:               PRG/421r13, Java Programming II

*           Instructor:        

*           Creation Date:   December 13, 2017

*

* Comments:

* Notice that in the abstract Animal class shown here, one method is

* concrete (the one that returns an animal's name) because all animals can

* be presumed to have a name. But one method, makeSound(), is declared as

* abstract, because each concrete animal must define/override the makeSound() method

* for itself--there is no generic sound that all animals make.

**********************************************************************/

package mytest;

// Animal is an abstract class because "animal" is conceptual

// for our purposes. We can't declare an instance of the Animal class,

// but we will be able to declare an instance of any concrete class

// that derives from the Animal class.

abstract class Animal {

// All animals have a name, so store that info here in the superclass.

// And make it private so that other programmers have to use the

// getter method to access the name of an animal.

private final String animalName;

// One-argument constructor requires a name.

public Animal(String aName) {

animalName = aName;

}

// Return the name of the animal when requested to do so via this

// getter method, getName().

public String getName() {

return animalName;

}

// Declare the makeSound() method abstract, as we have no way of knowing

// what sound a generic animal would make (in other words, this

// method MUST be defined differently for each type of animal,

// so we will not define it here--we will just declare a placeholder

// method in the animal superclass so that every class that derives from

// this superclass will need to provide an override method

// for makeSound()).

public abstract String makeSound();

};

// Create a concrete subclass named "Dog" that inherits from Animal.

// Because Dog is a concrete class, we can instantiate it.

class Dog extends Animal {

// This constructor passes the name of the dog to

// the Animal superclass to deal with.

public Dog(String nameOfDog) {

super(nameOfDog);

}

// This method is Dog-specific.

@Override

public String makeSound() {

return ("Woof");

}

}

// Create a concrete subclass named "Cat" that inherits from Animal.

// Because Cat is a concrete class, we can instantiate it.

class Cat extends Animal {

// This constructor passes the name of the cat on to the Animal

// superclass to deal with.

public Cat(String nameOfCat) {

super(nameOfCat);

}

// This method is Cat-specific.

@Override

public String makeSound() {

return ("Meow");

}

}

class Bird extends Animal {

// This constructor passes the name of the bird on to the Animal

// superclass to deal with.

public Bird (String nameOfBird) {

super(nameOfBird);

}

// This method is Bird-specific.

@Override

public String makeSound() {

return ("Squawk");

}

}

public class MyTest {

public static void main(String[] args) {

// Create an instance of the Dog class, passing it the name "Spot."

// The variable aDog that we create is of type Animal.

Animal aDog = new Dog("Spot");

// Create an instance of the Cat class, passing it the name "Fluffy."

// The variable aCat that we create is of type Animal.

Animal aCat = new Cat("Fluffy");

// Create an instance of (instantiate) the Bird class.

Animal aBird = new Bird("Tweety");

//Exercise two different methods of the aDog instance:

// 1) getName() (which was defined in the abstract Animal class)

// 2) makeSound() (which was defined in the concrete Dog class)

System.out.println("The dog named " + aDog.getName() + " will make this sound: " + aDog.makeSound());

//Exercise two different methods of the aCat instance:

// 1) getName() (which was defined in the abstract Animal class)

// 2) makeSound() (which was defined in the concrete Cat class)

System.out.println("The cat named " + aCat.getName() + " will make this sound: " + aCat.makeSound());

System.out.println("The bird named " + aBird.getName() + " will make this sound: " + aBird.makeSound());

}

}

In: Computer Science

An abstract report on test for carbohydrates

An abstract report on test for carbohydrates

In: Chemistry