Question
Answer the following questions by writing your answers. Before each answer, please write question number and question by using a bold font. B. 1) Shortly
Answer the following questions by writing your answers. Before each answer, please write question number and question by using a bold font.
B.1) Shortly explain interface with your own words.
B.2) Shortly explain abstract class with your own words and What are two important differences between an abstract class and an actual class? What are the similarities?
B.3) Shortly explain the popularity reason for the OOP.
B.4) Shortly explain the has-a and is-a relationship.
B.5) Shortly explain the No-parameter constructor behavior in java
B.6) Shortly explain the differences between this and super in java.
B.7) Shortly explain the unchecked and checked exceptions.
B.8) Shortly explain the visibility kinds in Java.
B.9) What will this program print according to Computer and Notebook implementation in the class?
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());
}
B.10) Explain the effect of each valid statement in the following fragment. Indicate any
invalid statements according to Computer and Notebook example which I give in the slides.
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());
B.11) 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