click below
click below
Normal Size Small Size show me how
OOP - Mod 6
| Question | Answer |
|---|---|
| Which of the following best describes single inheritance? a) A subclass can inherit from multiple superclasses b) A subclass inherits only from one superclass c) A class that cannot be inherited d) A superclass that inherits from a subclass | b) A subclass inherits only from one superclass |
| 1. What is the main purpose of encapsulation in Object-Oriented Programming? a) To ensure code reusability b) To make class variables public for better access c) To hide "sensitive" data from users d) To reduce the length of the code | Answer: c) To hide "sensitive" data from users |
| ____ variables can only be accessed within the same class (an outside class has no access to it) | Private |
| ________ is a technique of solving a problem and breaking it down into smaller parts and solving each of the smaller problems. | procedural programming |
| As a blueprint is a design for a house, a class is a design for a: | object |
| contains a reference to the current object being constructed. It represents an instance of the class in which it appears. It can be used to access class variables and methods | this keyword |
| contains a reference to the parent class (superclass) object. It is used to access members of a class inherited by the class in which it appears. It explicitly call a constructor of its immediate superclass. | super keyword |
| Encapsulation is also called as? | Data Hiding |
| Encapsulation is implemented by using__________ | private |
| How can Encapsulation be achieved? | using access specifiers |
| How can you call a parent class method from a subclass? a) By using this.method() b) By using parent.method() c) By using super.method() d) By overriding the method | c) By using super.method() |
| How can you make the private members inheritable? | It can be done both by making the visibility mode public or protected |
| How do I print out numbers on JAVA? | System.out.println(#); |
| How many classes can be inherited by a single class in java? | only 1 |
| How many types of inheritance can be used at a time in a single program? Any 4 types Any three types Any type, any number of times Any two types | Any type, any number of times |
| However, it is possible to accessprivate variables if we provide ___________ | public getter (accessor) and setter (mutator) methods |
| If a derived class object is created, which constructor is called first? | base class constructor |
| If data members are private, what can we do to access them from the class object? | Create public member functions to access those data members |
| If the super() call is omitted in the constructor of a subclass, what happens? | b) The default constructor of the superclass will be called implicitly |
| is a class that inherits all the non-private attributes and methods, except constructors from a superclass. This class has the ability to override methods of the superclass. Use protected specifier | subclass |
| is the class from which another class inherits properties. This is a class that is on top of a hierarchy. | superclass |
| is to make sure that "sensitive" data is hidden from users. | encapsulation |
| Sally is continuing work on her Object-Oriented Program and is writing code for a car, truck, and bus. These items under the class called vehicle are referred to as _____. | attributes |
| Single level inheritance is safer than _____________ | multiple inheritance |
| Single level inheritance will be best for___________ | Inheriting a class which can print all the calculation results |
| subclasses are derived from a single superclass. The derived class inherits the data members and methods of the superclass | single inheritance |
| subclasses are derived from more than one superclass. The derived class inherits the data members and methods its super classes. | multiple inheritance |
| t or f: Abstraction is the way to add functions in a user defined structure. | f |
| t or f: Accessor (Getter) – a method that is used to access or retrieve data. | t |
| t or f: Accessor (Getter) – a method that is used to change the data. | f |
| t or f: Attributes – declared either at the start or end of a class definition. These variables identify the data stored in the object. | t |
| t or f: Class Variables are variables stored in each object of a class, usually referred to as the non-static member fields of a class. | f |
| t or f: Class Variables are variables stored in the class and are available to all objects of a class or objects of other classes if access is permitted | t |
| t or f: Custom Methods – implement the business rules for which the application is being developed | t |
| t or f: Encapsulation has Better control of class attributes and methods | t |
| t or f: Encapsulation is implemented by using private | t |
| t or f: final Method: a method that cannot be overridden | t |
| t or f: In Encapsulation, the programmer can change one part of the code without affecting other parts | t |
| t or f: In Inheritance, the programmer can change one part of the code without affecting other parts | f |
| t or f: Instance Variables are variables stored in each object of a class, usually referred to as the non-static member fields of a class. | t |
| t or f: object-oriented programming, it is to break down a programming task into objects that expose behavior (methods) and data (members or attributes) using interfaces. | t |
| t or f: OOP is a technique of solving a problem and breaking it down into smaller parts and solving each of the smaller problems. | f |
| t or f: Procedural Programming describes the task to be performed on objects. | f |
| t or f: The private member's are made public to all the classes in inheritance. | f |
| t or f: There is an Increased security of data with Encapsulation | t |
| t or f: this - It can be used to access class variables and methods. | t |
| t or f: this keyword can be used to invoke current class method (implicitly) | t |
| The technique of deriving new class definitions from an existing class definition | inheritance |
| The this keyword is ____________ | used to refer to the current object |
| this – contains a reference to the current object being constructed | t |
| true or false: Custom Methods – implement the business rules for which the application is being developed | t |
| Using encapsulation data security is ___________ | ensured to some extent |
| What is inheritance in Object-Oriented Programming? | b) Creating subclasses that reuse the attributes and methods of a superclass |
| What is the purpose of the super keyword in Java? a) It refers to the child class object b) It is used to call the parent class constructor or methods c) It creates an instance of the current class d) It hides the attributes of the superclass | b) It is used to call the parent class constructor or methods |
| What is the purpose of the this keyword in a setter method? a) It refers to the method's local variable b) It refers to the object being created or modified c) It refers to the method’s argument d) It refers to the class itself | b) It refers to the object being created or modified |
| What is the result of making a class final in Java? a) The class can no longer be instantiated b) The class can no longer be inherited c) The class can no longer have any methods d) The class can no longer have private variables | b) The class can no longer be inherited |
| What will happen if a subclass does not override a method from its superclass? a) Compilation error b) The subclass cannot be instantiated c) The subclass will inherit and use the method from the superclass d) The superclass method will be removed | c) The subclass will inherit and use the method from the superclass |
| What will happen if you try to access a private class variable directly from a method outside the class? | a) Compilation error |
| When Overloading does not occur? | More than one method with same name, same signature, same number of parameters but different type |
| Which among the following best describes encapsulation? | It is a way of combining various data members and member functions that operate on those data members into a single unit |
| Which among the following defines single level inheritance? | One derived class inherits from one base class |
| Which among the following defines single level inheritance? One derived class derives from another derived class One derived class inherits from one base class One base class derives another class One base class inherits from one derived class | One base class derives another class |
| Which among the following is false for single level inheritance? | There can be more than 2 independent classes involved in single inheritance |
| Which concept of Java is a way of converting real world objects in terms of class? | abstraction |
| Which concept will result in derived class with more features (consider maximum 3 classes)? | Multiple inheritance |
| Which feature can be implemented using encapsulation? | abstraction |
| Which of following statement(s) can result in new object instance creation if executed successfully. All String str = new String("VirtuQ"); String str = new String(); int [] arr = {1,2,3,4,5}; String str = "VirtuQ" + " "+ Simplifying Education"; | all |
| Which of the following is an advantage of encapsulation? | c) It provides flexibility by controlling how class variables are accessed and updated |
| Which of the following is not an advantage to using inheritance? | One big superclass can be used instead of many little classes. |
| Which of the following keywords is used to inherit attributes and methods from one class into another? a) this b) super c) extend d) implements | c) extend |
| Which of the following statements about setter and getter methods is correct? | c) Getter methods are used to read private variables |
| Which programming language doesn't support multiple inheritance? | java |