(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)
// 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(); } }
Get Answers For Free
Most questions answered within 1 hours.