Question

(Please use java to write these questions) Q1. Create a class on an object Computer with...

(Please use java to write these questions)

Q1. Create a class on an object Computer with two fields and two methods as follows: (5 points)

field: cpu and memory, method: compile( ) and execute( )

Q2. Write a source code to activate a class created in Q1. (5 points)

Homework Answers

Answer #1
// Q1
class Computer {
    private String cpu;
    private String memory;

    public Computer() {
    }

    public Computer(String cpu, String memory) {
        this.cpu = cpu;
        this.memory = memory;
    }

    public void compile() {
        System.out.println("Program is compiled...");
    }

    public void execute() {
        System.out.println("Program is executed...");
    }
}

// Q2
class ComputerTest {

    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.compile();
        computer.execute();
    }
}

Know the answer?
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
Similar Questions
Coding in Java Create an Airplane class (not abstract) that uses the Vehicle interface in Q1....
Coding in Java Create an Airplane class (not abstract) that uses the Vehicle interface in Q1. The code for all methods should print simple messages to the screen using System.out.println(). Add an integer speed variable that is changed using ChangeSpeed method. ChangeSpeed adds 5 to the speed each time it is called. Create a default constructor that sets the initial speed to 0. Don't create other constructors or any setter/getter methods. // code from Q1: interface Vehicle { void Start();...
(JAVA) Create a class that represents a Customer. Use good OO programming technique. A Customer has...
(JAVA) Create a class that represents a Customer. Use good OO programming technique. A Customer has a firstName, lastName, customerNumber, emailAddress. You can add some more fields if you want to, but those 4 are a minimum. Override the equals method, and the toString method from the Object class. Implement the Comparable interface. In the main method, create some instances of the Customer class, and demonstrate the use of the accessor and mutator methods, as well as the compareTo method.
Q1: Use the setCharAt() method in StringBuilder class to edit a String "java". After editing it,...
Q1: Use the setCharAt() method in StringBuilder class to edit a String "java". After editing it, the String will be "Java". Q2: Write a Java program to define the ListNode in the LinkedList:
Create an Airplane class (not abstract) that uses the Vehicle interface in Q1. The code for...
Create an Airplane class (not abstract) that uses the Vehicle interface in Q1. The code for all methods should print simple messages to the screen using System.out.println(). Add an integer speed variable that is changed using the ChangeSpeed method. ChangeSpeed adds 5 to the speed each time it is called. Create a default constructor that sets the initial speed to 0. Don't create other constructors or any setter/getter methods. PLEASE CODE THIS IN JAVA
C++ Design a class named Computer that holds the make, model, and amount of memory of...
C++ Design a class named Computer that holds the make, model, and amount of memory of a computer. Include methods to set the values for each data field, and include a method that displays all the values for each field. Create the class diagram and write the pseudocode that defines the class. Pseudocode help please
Write the program in java Implement a class Product. Create instance variables to store product name...
Write the program in java Implement a class Product. Create instance variables to store product name and price and supply the values through constructor. For example new Product(“Toaster’, 29.95). Create methods, getName, getPrice. Write a method productPrinter that prints the product name and its price after reducing it by $5. Create a main class and necessary constructs in the main class to run the Product class.
Casting class objects 1.2 Compile and execute the code listed below as it is written. Run...
Casting class objects 1.2 Compile and execute the code listed below as it is written. Run it a second time after uncommenting the line obj.speak();. public class AnimalRunner {    public static void main(String[] args)    {       Dog d1 = new Dog("Fred");       d1.speak();       Object obj = new Dog("Connie");       // obj.speak();    } } The uncommented line causes a compile error because obj is an Object reference variable and class Object doesn’t contain a speak() method. This...
1.Write a program that instantiates an object from the computer class and writes data into the...
1.Write a program that instantiates an object from the computer class and writes data into the object. you can set the data internally in the program. You do not need to ask for keyboard input. 2. Create a method that displays the data inside the computer object.
Java Create a new Drive class. * Create a Menu class. * The menu class will...
Java Create a new Drive class. * Create a Menu class. * The menu class will use the previous 4 classes you created in GCD, LCM, FACTORIAL, DIGITS The Menu will display a menu that give you the option of selecting: 1) Greatest Common Denominator 2) Lowest Common Multiple 3) Factorial 4) Number of Digits in an Integer Enter 1,2,3 or 4: When the User enter the choice, then the correct function/method is called for the class and asks the...
write code using python or repl.it 1. List 4 attributes that you'd create for class "student"....
write code using python or repl.it 1. List 4 attributes that you'd create for class "student". 2. List 2 setters and 2 getters for class student including their parameters 3. Write the complete definition for class student including attributes and methods created above using the correct Python syntax. 4. Create one object of class student and print the values of all its attributes. You can either call the getter method or access the attribute directly using the dot notation.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Your company is thinking of introducing a Bring Your Own Device (BYOD) policy. You have been...
    asked 8 minutes ago
  • Attached is the file GeometricObject.java. Include this in your project, but do not change. Create a...
    asked 10 minutes ago
  • Suppose the number of cars in a household has a binomial distribution with parameters n =...
    asked 13 minutes ago
  • HR needs some information on the new interns put into a database. Given an id, email,...
    asked 34 minutes ago
  • Problem solving strategies Questions years = input("Enter a number of years and I'll tell you how...
    asked 38 minutes ago
  • Calculate ?Hrxn for the following reaction: CH4(g)+4Cl2(g)?CCl4(g)+4HCl(g) Use the following reactions and given ?H?s. C(s)+2H2(g)?CH4(g)?H=?74.6kJC(s)+2Cl2(g)?CCl4(g)?H=?95.7kJH2(g)+Cl2(g)?2HCl(g)?H=?184.6kJ Express...
    asked 45 minutes ago
  • ASCII (American Standard Code for Information Interchange) has an encoding for every character of the alphabet,...
    asked 59 minutes ago
  • Is home confinement with electronic monitoring a deterrent? Are there negatives to being confined to one’s...
    asked 1 hour ago
  • Social hostility can have severe lasting effects of interperpersonal relationship during our adolescence years, which if...
    asked 1 hour ago
  • - A series RLC circuit has R=15 ?, L=1.5 H, and C=15 ?F. (a) For what...
    asked 1 hour ago
  • TV Circuit has 30 large-screen televisions in a warehouse in Erie and 60 large-screen televisions in...
    asked 1 hour ago
  • Charges q1, q2, q3, and q4 are placed in sequential order at the corners of a...
    asked 1 hour ago