Question
JAVA 1) What will this program print? Computer comp[] = new Computer[3]; comp[0] = new Computer(Ace, AMD, 8, 750, 3.5); comp[1] = new Notebook(Dell, Intel,
JAVA
1) What will this program print?
Computer comp[] = new Computer[3];
comp[0] = new Computer("Ace", "AMD", 8, 750, 3.5);
comp[1] = new Notebook("Dell", "Intel", 4, 500, 2.2, 15.5, 7.5);
comp[2] = comp[1];
for (int i = 0; i < comp.length; i++) {
System.out.println(comp[i].getRamSize() +" " +
comp[i].toString());
}
2) Explain the effect of each valid statement in the following fragment. Indicate any
invalid statements.
Computer c1 = new Computer();
Computer c2 = new Computer("Ace", "AMD", 8.0, 500, 3.0);
Computer c3 = new Notebook("Ace", "AMD", 4.0, 500, 3.0);
Notebook c4 = new Notebook("Bravo", "Intel", 4.0, 750, 3.0, 15.5, 5.5);
System.out.println(c2.manufacturer + "," + c4.processor);
System.out.println(c2.getDiskSize() + "," + c4.getRamSize());
System.out.println(c2.toString() + " " + c4.toString());
3) Correct each of the following statements that are incorrect, assuming that class PDGUI and class PDConsoleUI implement interface PDUserInterface.
a. PDGUI p1 = new PDConsoleUI();
b. PDGUI p2 = new PDUserInterface();
c. PDUserInterface p3 = new PDUserInterface();
d. PDUserInterface p4 = new PDConsoleUI();
e. PDGUI p5 = new PDUserInterface(); PDUserInterface p6 = p5;
f. PDUserInterface p7; p7 = new PDConsoleUI();
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started