OOPS Concepts Test

1. What is a primary motivation for using OOP?
Answers:
• To increase data coupling.
• Because other programming paradigms have become obsolete.
• To increase reusability and maintainability of code.
• To increase speed of writing code.
2. Why is dynamic binding referred to as “late binding”?
Answers:
• It is never bound.
• It is bound at compile time.
• It is not bound at compile time.
• It is not bound at runtime.
3. A mutator method is also known as a:
Answers:
• getter
• setter
• updater
• deleter
4. True or false? Polymorphism means to support multiple inheritance.
Answers:
• True
• False
5. Which of the following could be considered a polymorphism?
Answers:
• The class, “clsCalculation” with two functions, both named “Add”.
• Two classes named “add”.
• Two functions named “clsCalculation”.
• Two classes named “clsCalculation” with the single function, “add”.
6. What is the most important trait of a polymorphism?
Answers:
• The common interface.
• The multiple interfaces.
• The difference in interface.
• The total differences.
7. A trait is:
Answers:
• a collection of methods
• another word for class
• another word for interface
8. Why is composition considered a simpler method than inheritance?
Answers:
• Composition lacks the namespace clash, and the complicated inheritance hierarchies.
• It isn't considered a simpler method.
• It is filled with complicated inheritance hierarchies.
• Composition has complex namespace clashes.
9. Can an object have more than one instance?
Answers:
• Yes, but it will result in errors.
• Yes, but they must be in two different physical locations.
• Yes.
• No.
10. Ref counts are:
Answers:
• a way of managing object lifetimes
• magic methods on all classes
• how wrestling referees determine a winner
• an optimization for compilers
11. 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.
Answers:
• False
• only if $count is static in both uses
• True
12. What are objects identified by?
Answers:
• Their orientation within a program.
• Their qualities.
• Their relationship with other objects.
• Their unique name.
13. In most OOP languages virtual methods are:
Answers:
• not callable directly
• statically dispatched
• dynamically dispatched
14. What is another name for the composition over inheritance technique?
Answers:
• Constant Refurbishment Practices
• Composite Reuse Principle
• Comcast Reuse Principle
• Compost Reuse Principle
15. What kind of relationship is the public class “Animal” with the extension, “Mammal” demonstrating?
Answers:
• WAS-A Relationship
• IS-NOT-A Relationship
• IS-A Relationship
• HAS-A Relationship
16. True or false? Using traits gives single inheritance languages most of the power of multiple inheritance.
Answers:
• False
• True
17. If you wrote two methods with the same syntax and arguments to define a class, what would happen?
Answers:
• The compiler would compile them separately in different instances, thus resolving any errors.
• The compiler would ignore both of them.
• The compiler would assume a meaning and compile automatically.
• An error because the compiler can't tell them apart.
18. Static binding is also known as what?
Answers:
• Runtime binding.
• Late binding.
• Early binding.
• Dynamic binding.
19. When does binding occur with static binding?
Answers:
• Never.
• After runtime binding occurs.
• At runtime.
• At compile time.
20. The diamond problem refers to:
Answers:
• a common problem in single inheritance hierarchies
• a standard interview question for programmers
• a very hard computer program, refering to the Mohs scale
• the multiple inheritance issue of determining which subclass method to call
21. If a user were to observe Java code from the outside world, what would they be able to access?
Answers:
• The private methods.
• All of the code in the program.
• The Java console.
• The public methods.
22. True or false? the final keyword blocks a child class from altering a method.
Answers:
• True
• False
23. Which of the following classes allows only one object of it to be created?
Answers:
• Friend class
• Abstract class
• Virtual class
• Singleton class
24. True or false? .Encapsulation is a key reason to choose OOP design
Answers:
• False
• True
25. Dynamic binding refers to binding that is done when?
Answers:
• At both compile time, and runtime.
• At runtime only.
• At night.
• At compile time.
26. If a variable is declared to be default, what kind of modifier does it have?
Answers:
• Alphabetical.
• Truncated.
• Numeric.
• It has no modifiers.
27. True or false? An interface is another name for a class.
Answers:
• True
• False
28. Patterns are:
Answers:
• solved computer science problems that are easy to reuse
• unpredictable
• another word for interfaces
• for weenies and should be avoided
29. When an object is instantiated:
Answers:
• it gets a static initialization
• the new method is called
• the constructor method is called
• the init method is called
30. How can dynamic binding be contrasted with static binding?
Answers:
• Static binding is better than dynamic binding.
• Dynamic binding is runtime binding, while static binding is compile time binding.
• Dynamic binding is compile time binding, while static binding is runtime binding.
• They are bound together with polymorphic compiling.
31. True or false? Implementing an interface is the same as creating a subclass
Answers:
• True
• False
32. A polymorphism can be called what?
Answers:
• The order of objects in a sequence.
• A relationship between two objects.
• Functions that perform the same way.
• A function that performs in different ways.
33. True or false? Private methods can be called by subclasses
Answers:
• True
• False
34. If you wanted a variable to be free from changes outside its class, how should it be declared?
Answers:
• Encapsulated.
• Private.
• Free.
• Public.
35. What is encapsulation used for?
Answers:
• Encapsulation is used to isolate malicious code.
• Encapsulation is used to hide programmers from code.
• Encapsulation is used to prevent unauthorized access to code.
• Encapsulation is used to hide code from programmers.
36. Static functions can use which variables?
Answers:
• public
• private and static
• static
• private
37. True or false? A class factory and a constructor are the exact same thing.
Answers:
• False
• True
38. What is a simple way to think of inheritance?
Answers:
• One object acquiring the properties of another.
• New properties written from scratch.
• One object generating another object.
• One object writing new properties for another.
39. Which of these concepts is not an OOP concept?
Answers:
• encapsulation
• semantics
• decoupling
• inheritance
40. What are method names typically restricted by?
Answers:
• Grammatical rules.
• Ethical rules.
• The alphabet.
• Code conventions.
41. Public variables are visible outside of the class.
Answers:
• only through methods
• True
• False
• only to subclasses
42. C is an object oriented language
Answers:
• False
• True
43. True or false? A class can implement one or more interfaces.
Answers:
• False
• True
44. C++ is an object oriented language
Answers:
• True
• False
45. OOP stands for:
Answers:
• object oriented programming
• objectively oriented programmers
• oops!
• oblong object programming
46. When a variable is defined within a class, what is it considered?
Answers:
• An early variable.
• An instance variable.
• A class variable.
• A varying variable.
47. Which of the following is included in the field of formal semantics?
Answers:
• The comprehension of relational models.
• The understanding of programming models.
• The definition of semantic models.
• The definition of logistic models.
48. Lambda functions are allowed in class definitions
Answers:
• True
• False
49. True or false? Static variables are visible outside of the class
Answers:
• False
• True
• depends
50. An abstract class can:
Answers:
• Be subclassed
• Only contain abstract methods
• Be instantiated
51. Semantically, what has happened if the result rendered is non-computational?
Answers:
• A system failure.
• Syntactically illegal strings have occurred.
• A program corruption.
• Syntactically legal strings have occurred.
52. True or false? Abstract methods are only defined in the parent.
Answers:
• False
• True
53. When two methods have the same name, what are they considered, and what kind of binding do they have?
Answers:
• Overloaded, late.
• Overhauled, static.
• Overloaded, dynamic.
• Overloaded, static.
54. A clone method is needed to:
Answers:
• make any copies of this object
• make any copies of the parent object
• to create a second copy of all contained subobjects
• make any copies of children objects
55. Programming languages supporting the OOPS paradigm are typically contained within what two classes?
Answers:
• OOPS-based and object-based
• Prototype-based, or class-based.
• Logic-based and inference-based.
• System based and program-based.
56. What are classes used for?
Answers:
• Classes are used to define specific types.
• Classes are used to manage metadata.
• Classes describe different features.
• Classes define objects.
57. What class and extension best demonstrate a HAS-A Relationship?
Answers:
• Feline, Canine
• Feline, Animal
• Feline, Lion
• Canine, Mammal
58. Virtual inheritance is:
Answers:
• where only one base class object is created
• the base class is replicated for each derived class
• where virtually nothing is inherited
• not an OOP term
59. True or false? Private variables are visible outside of the class.
Answers:
• only through methods
• only to subclasses
• False
• True
60. If a system is systematically computing “metadata”, what would you use to define that system?
Answers:
• Accentuated grammars.
• Attribute phonetics.
• Attribute grammars.
• Programming metadata.
61. What plays a critical role in testing for syntactic legality?
Answers:
• Syntactic congruency.
• Termination proofs.
• Logical assumptions.
• Mathematical truths.

No comments:

Post a Comment