GoConqr has a new look! Let us know what you think.

Quiz

EECS 2030

Junaid Khan 39 questions Updated 17 Jan 2019

Take the quiz

Questions in this quiz (39)

  1. 1Interfaces and Inheritance- What is an interface?
    1. Aan abstract class
    2. Ban abstract class that other classes may extend
    3. Ca class
    4. Da class that other classes may extend
    5. Ea declaration of an API
  2. 2 Interfaces and Inheritance- Java supports single inheritance; what does the term single inheritance mean?
    1. Aevery class has exactly one parent class
    2. Bevery class has exactly one child class
    3. Cevery class implements exactly one interface
    4. Devery class inherits from Object
  3. 3Interfaces and Inheritance- Consider the following classes related by inheritance:
    See Figure: pg 11 of 28
    Question 27
    Assuming A, B, and C all have public no-argument constructors, which of the following variable definitions are legal?
    1. AA a = new B();
    2. BB b = new A(); (*)
    3. CC c = new B(); (**)
    4. DC c = new A(); (***)
    5. EB (*)and C (**)
    6. FB(*) C(**) D(***)
    7. GNone of the expression is legal
  4. 4Interfaces and Inheritance-Consider the following classes related by inheritance:
    Which of the following statements is the most accurate and complete regarding the class C?
    1. AC inherits all of the fields and methods from A
    2. BC inherits all of the fields and methods from B
    3. CC inherits all of the fields and methods from A and B 11/28 Q28
    4. DC inherits all of the fields and methods from A and B and may add its own fields and methods
    5. EC is made up of an A subobject
    6. FC is made up of an B subobject
    7. GC is made up of an A subobject and a B subobject
  5. 512/28 Q29.
    Consider the following two classes related by inheritance:
    public class AdultCat {
    private int size; /* INVARIANT: this.size > 0 && this.size <= 10 */
    public AdultCat(int size) {
    /* IMPLEMENTATION NOT SHOWN */
    }
    /**
    * Sets the size of this cat to be equal to sz. If sz is greater than 10
    * then the size of this cat is set to some value between 1 and 10.
    *
    * @param sz the desired size of this cat
    * @pre. sz is greater than 0
    */
    public void setSize(int sz) {
    /* IMPLEMENTATION NOT SHOWN */
    }
    }
    public class Lion extends AdultCat {
    public Lion(int size) {
    /* MISSING STATEMENT */
    }
    /**
    * Sets the size of this cat to be equal to sz. If sz is greater than 10
    * then /* MISSING POSTCONDITION */
    *
    * @param sz the desired size of this cat
    * @pre. /* MISSING PRECONDITION */
    */
    @Override
    public void setSize(int sz) {
    /* IMPLEMENTATION NOT SHOWN */
    }
    }


    What can the line with the comment /* MISSING STATEMENT */ be replaced with in the Lion constructor?
    1. Asuper(size);
    2. Bthis(size);
    3. Cthis.setSize(size);
    4. Dthis.size = size;
  6. 6** REFER TO Q29.
    Interfaces and Inheritance
    - The precondition of the Lion version of setSize is incomplete (ends with
    /* MISSING PRECONDITION */); which of the following can be used to complete the precondition
    so that Lion is substitutable for AdultCat?
    1. Asize is greater than 0 and less than 10
    2. Bsize is greater than 0 and less than 11
    3. Csize is greater than 1
    4. Dsize is greater than -1
    5. Esize is not equal to 0
  7. 7Interfaces and Inheritance-
    **REfere to Q29**
    Can the AdultCat constructor be safely implemented like so?:
    public AdultCat(int size) {
    this.setSize(size);
    }
    1. Ano, the postcondition of setSize does not guarantee that the class invariant is true
    2. Bno, setSize is not a final method
    3. Cyes, setSize can be overridden by child classes
    4. Dyes, using setSize minimizes code duplication
  8. 8Class Features-What is an obligatory method?
    1. Aa method that can be invoked using any object reference.
    2. Ba method that the client must invoke, such as a constructor.
    3. Ca method that the implementer must override.
    4. Da method that the implementer must not override
  9. 9Class Features-What is a class invariant?
    1. Aa condition that the method promises will be true immediately after the method finishes running
    2. Ba condition that the method must check at the beginning of the method
    3. Ca condition that the user (client) must ensure is true before calling the method
    4. D. a condition that is always true immediately after a constructor or method finishes running
  10. 10 Class Features-Which statement is true for a static attribute (or field) of a class X?
    1. AThe class X has one copy of the attribute for every x object.
    2. BThe class X has the only copy of the attribute
    3. CEach X object has its own copy of the attribute
    4. DOnly objects of classes that extend X have a copy of the attribute.

Information

Description
Set of Final Question
Language
English
Views
166
History
Created on 5 Jan 2019 · updated on 17 Jan 2019
Rating
No ratings yet
Rate this quiz
Rate this quiz

Feedback

What is it about?

What do you think of the new look?

How do you like it?