Thursday, July 30, 2015

OOPS Concepts Test Questions




A polymorphism can be called what?
  • A relationship between two objects.
  • The order of objects in a sequence.
  • A function that performs in different ways.
  • Functions that perform the same way.
Answer: A function that performs in different ways.
How can dynamic binding be contrasted with static binding?
  • They are bound together with polymorphic compiling.
  • Dynamic binding is compile time binding, while static binding is runtime binding.
  • Static binding is better than dynamic binding.
  • Dynamic binding is runtime binding, while static binding is compile time binding.
Answer: Dynamic binding is runtime binding, while static binding is compile time binding.
What is a simple way to think of inheritance?
  • One object generating another object.
  • One object acquiring the properties of another.
  • One object writing new properties for another.
  • New properties written from scratch.
Answer: One object acquiring the properties of another.
When does binding occur with static binding?
  • At runtime.
  • Never.
  • At compile time.
  • After runtime binding occurs.
Answer: At compile time.
A clone method is needed to:
  • make any copies of the parent object
  • make any copies of children objects
  • to create a second copy of all contained subobjects
  • make any copies of this object
Answer: to create a second copy of all contained subobjects
What are classes used for?
  • Classes are used to manage metadata.
  • Classes define objects.
  • Classes are used to define specific types.
  • Classes describe different features.
Answer: Classes are used to define specific types.
Programming languages supporting the OOPS paradigm are typically contained within what two classes?
  • Logic-based and inference-based.
  • Prototype-based, or class-based.
  • System based and program-based.
  • OOPS-based and object-based
Answer: Prototype-based, or class-based.
When two methods have the same name, what are they considered, and what kind of binding do they have?
  • Overloaded, static.
  • Overloaded, late.
  • Overloaded, dynamic.
  • Overhauled, static.
Answer: Overloaded, static.


What is a primary motivation for using OOP?
  • To increase speed of writing code.
  • To increase reusability and maintainability of code.
  • To increase data coupling.
  • Because other programming paradigms have become obsolete.
Answer: To increase reusability and maintainability of code.
Ref counts are:
  • a way of managing object lifetimes
  • how wrestling referees determine a winner
  • magic methods on all classes
  • an optimization for compilers
Answer: a way of managing object lifetimes
When a variable is defined within a class, what is it considered?
  • A varying variable.
  • An early variable.
  • A class variable.
  • An instance variable.
Answer: An instance variable.
Why is dynamic binding referred to as “late binding”?
  • It is not bound at compile time.
  • It is bound at compile time.
  • It is not bound at runtime.
  • It is never bound.
Answer: It is not bound at compile time.





Static functions can use which variables?
  • private and static
  • public
  • private
  • static
Answer: static
What are objects identified by?
  • Their qualities.
  • Their relationship with other objects.
  • Their orientation within a program.
  • Their unique name.
Answer: Their unique name.
Which of the following could be considered a polymorphism?
  • Two classes named “clsCalculation” with the single function, “add”.
  • Two functions named “clsCalculation”.
  • The class, “clsCalculation” with two functions, both named “Add”.
  • Two classes named “add”.
Answer: The class, “clsCalculation” with two functions, both named “Add”.
Can an object have more than one instance?
  • Yes.+58pts
  • No.
  • Yes, but they must be in two different physical locations.
  • Yes, but it will result in errors.
Answer: Yes





A mutator method is also known as a:
  • Setter
  • deleter
  • updater
  • getter
Answer: Setter
True or false? Static variables are visible outside of the class
  • depends
  • False
  • True
Answer: depends
An abstract class can:
  • Be subclassed
  • Only contain abstract methods
  • Be instantiated
Answer: Be subclassed
A trait is:
  • another word for class
  • another word for interface
  • a collection of methods
Answer: a collection of methods








What is the difference between interfaces and abstract classes?
  • interfaces cannot have methods whereas abstract classes can
  • interfaces cannot have properties whereas abstract classes can
  • abstract classes can provide default implementation whereas interfaces cannot provide implementations
  • interfaces can provide default implementation whereas abstract classes cannot provide implementations
Answer: abstract classes can provide default implementation whereas interfaces cannot provide implementations
Why is composition considered a simpler method than inheritance?
  • It isn't considered a simpler method.
  • Composition has complex namespace clashes.
  • It is filled with complicated inheritance hierarchies.
  • Composition lacks the namespace clash, and the complicated inheritance hierarchies.
Answer: Composition lacks the namespace clash, and the complicated inheritance hierarchies.
True or false? Abstract methods are only defined in the parent.
  • False
  • True
Answer: False
True or false? Polymorphism means to support multiple inheritance.
  • True
  • False
Answer: False



What is the most important trait of a polymorphism?
  • The common interface.
  • The total differences.
  • The multiple interfaces.
  • The difference in interface.
Answer: The common interface.
True or false? It's legal to have two variables both named $count where one is a global variable and the other is used inside a class.
  • only if $count is static in both uses
  • False
  • True
Answer: True
What are method names typically restricted by?
  • Code conventions.
  • The alphabet.
  • Grammatical rules.
  • Ethical rules.
Answer: Code conventions.
Which of the following is included in the field of formal semantics?
  • The comprehension of relational models.
  • The definition of semantic models.
  • The understanding of programming models.
  • The definition of logistic models.
Answer: The definition of semantic models.




What kind of relationship is the public class “Animal” with the extension, “Mammal” demonstrating?
  • HAS-A Relationship
  • IS-A Relationship
  • WAS-A Relationship
  • IS-NOT-A Relationship
Answer: IS-A Relationship
Lambda functions are allowed in class definitions
  • False
  • True
Answer: False














No comments:

Post a Comment