{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cop3xxxreview

cop3xxxreview - Review Q1 Given the following piece of code...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Review Q1. Given the following piece of code: public class A { public A(){} } public class B extends A { public B(){} } public class driver { public static void main(String[] arg) { A a = new B(); B b = new A(); } } What will happen when you try to compile it? Explain. Q2. Given the following piece of code: abstract class A { A(){ } int abstract method1(); void abstract method2(); } abstract class B extends A { super(); int method2() { return 0; } } What will happen when you try to compile it? Explain. Q3. Indicate true or false for the following statements. (i) A final class can have instances. (ii) A final class can be extended. (iii) A final class can be implemented. (iv) An abstract class can be extended (v) An abstract class cannot be inherited. (vi) A concrete class does not have to define all of the abstract methods that it inherits from an abstract class. 1
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Q4. What output is generated from the following program? class A { void print() { System.out.println("a is not an instance of B"); } } class B extends A { void print() { System.out.println("b is an instance of A"); } } class Tester { public static void main(String[] arg)
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern