click below
click below
Normal Size Small Size show me how
OOP MOD 5&6
| Question | Answer |
|---|---|
| Which of the following is a mechanism by which object acquires the properties of another object? | Inheritance |
| The focus of procedural programming is to break down a programming task into a collection of variables, data structures, and subroutines | true |
| Which of following statement(s) can result in new object instance creation if executed successfully. All int [] arr = {1,2,3,4,5}; String str = "VirtuQ" + " "+ Simplifying Education"; String str = new String("VirtuQ"); String str = new String(); | All |
| OOP is a technique of solving a problem and breaking it down into smaller parts and solving each of the smaller problems. | false |
| Where does a java program start executing instructions from: | main method |
| Constructor – a method that is automatically executed when an object is created. This method is used to initialize the attributes. | true |
| this keyword can be used to invoke current class method (implicitly) | true |
| a method that is only accessible within the class where it is declared. | private method |
| Standard Methods – used to change or access the private data in an object. | true |
| a variable that is accessible within and outside the package but through inheritance only. | protected variable |
| 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 |
| In Encapsulation, Class variables can be made read-only or write-only | true |
| In Inheritance, the programmer can change one part of the code without affecting other parts | false While inheritance promotes code reusability, changing a parent (superclass) can still affect all its child (subclass) implementations |
| Encapsulation is supported by ___________ | Classes |
| Encapsulation is implemented by using__________ | private |
| Which among the following best describes the Inheritance? | Using the data and functions into derived segment |
| Which concept will result in derived class with more features (consider maximum 3 classes)? | Multiple inheritance |
| Single level inheritance is safer than _____________ | Multiple inheritance |
| Which type of inheritance cannot involve private inheritance? | All types can have private inheritance |
| The private member's are made public to all the classes in inheritance. | False In inheritance, private members are never made public. |
| Which of the following concept is often expressed by the phrase, 'One interface, multiple methods'? | Polymorphism |
| How do I print out numbers on JAVA? | System.out.println(#); |
| What is the difference between a class and an object? | A class is a blueprint to make an object |
| Procedural Programming is a technique of solving a problem and breaking it down into smaller parts and solving each of the smaller problems. | true Procedural Programming solves problems by breaking them into smaller parts called procedures (functions/subroutines) |
| a variable that is only accessible within a class where it is declared | private variable |
| final Method: a method that cannot be overridden | final Method: a method that cannot be overridden |
| Custom Methods – implement the business rules for which the application is being developed | true |
| _________– used to change or access the private data in an object. | Standard Methods |
| static 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 | True In Java, static variables: - Belong to the class, not to individual objects. - Are shared among all objects of the class (only one copy exists). |
| There is no security of data with Encapsulation | false Encapsulation actually provides security of data by hiding the internal details of a class (using private variables) and allowing controlled access through getters and setters. |
| Encapsulation is implemented by using private | true |
| While using encapsulation, which among the following is possible? | Data member's data type can be changed without changing any other code |
| How can Encapsulation be achieved? | Using Access Specifiers |
| If a derived class object is created, which constructor is called first? | Base class constructor |
| How many types of inheritance can be used at a time in a single program? | Any type, any number of times |
| The private members of the base class are visible in derived class but are not accessible directly. | True |
| Single level inheritance will be best for___________ | Inheriting a class which can print all the calculation results |
| object-oriented programming, it is to break down a programming task into objects that expose behavior (methods) and data (members or attributes) using interfaces. | true |
| A _____ is a procedure associated with a class that describes an action an object is able to perform. | method |
| The wrapping up of data and functions into a single unit is called | encapsulation |
| Which of the following is not OOPS concept in Java? | Compilation |
| this keyword can be passed as argument in the constructor call. | true |
| Instance 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 | false Variables declared in a class but outside any method. Stored separately in each object of the class. Each object has its own copy of instance variables. |
| Attributes – declared either at the start or end of a class definition. These variables identify the data stored in the object. | true |
| Encapsulation has Better control of class attributes and methods | true |
| Which among the following violates the principle of encapsulation almost always? | Global variables |
| Which among the following is correct for a hierarchical inheritance? | One base class can be derived into only 2 classes One base class can be derived into other two derived classes or more (this one and) Two or more classes can be derived into one class (this one) Two base classes can be used to be derived into one |
| Which is the correct syntax of inheritance? | class derived_classname : access base_classname{ /*define class body*/ }; ????????????????????? |
| Which language doesn't support single level inheritance? | All languages support it |
| Which access type data gets derived as private member in derived class? | Private |
| When Overloading does not occur? | More than one method with same name, same number of parameters and type but different signature |
| Which statement(s) best describes inheritance? | The child object inherits from its parent, adding specialized attributes and behavior. One object (the child) generalizes the attributes and behavior of another object (the parent), making the object more generalized. W |
| static Variable used in defining a class variable | true |
| These variables identify the data stored in the object. | Attributes |
| this can be used to refer current class instance variable. | true this keyword is used to refer to the current class’s instance variables. It is often used to resolve naming conflicts between instance variables and parameters. |
| a method that is accessible within and outside the package but through inheritance only. | protected |
| Encapsulation is also called as? | Data Hiding |
| Abstraction is the way to add functions in a user defined structure. | False |
| How can you make the private members inheritable? | It can be done both by making the visibility mode public or protected |
| In hierarchical inheritance, all the classes involve some kind of inheritance. | False |
| Members which are not intended to be inherited are declared as ________________ | Private members |
| Procedural Programming describes the task to be performed on objects. | false |
| Which of the these is the functionality of 'Encapsulation'? | Binds together code and data |
| True or False: // allows for a single line comment? | True |
| Method overriding is combination of inheritance and polymorphism? | True |
| Global Variables are variables used in a method | false Variables used inside a method are called local variables, not global variables. |
| Custom Methods – used to change or access the private data in an object. | false |
| Accessor (Getter) – a method that is used to access or retrieve data. | true |
| Class Variables are variables stored in each object of a class, usually referred to as the non-static member fields of a class. | false |
| Which feature can be implemented using encapsulation? | Abstraction Encapsulation helps implement abstraction by hiding the internal details of a class and exposing only the necessary methods to interact with the object. |
| What type of inheritance does Java have? | Single Inheritance, where a class can inherit from one superclass only. |
| Encapsulation has poor control of class attributes and methods | false |
| Which among the following defines single level inheritance? | One derived class inherits from one base class |
| Which constructor will be called first from the classes involved in single inheritance from object of derived class? | Base class constructor |
| If single inheritance is used, program will contain ________________ | At least 2 classes |
| When does method overloading is determined? | At compile time |
| Which of the following is a type of polymorphism in Java? | Compile time polymorphism |
| final Variable: constant variable | true In Java, when you declare a variable with the final keyword, it becomes a constant — meaning its value cannot be changed once assigned. |
| non-static Variables are variables stored in each object of a class, usually referred to as the non-static member fields of a class. | true Non-static variables (also called instance variables) are created separately for each object of a class. |
| Local Variables are variables used in a method | true |
| a method a method that is accessible from all classes. | public method |
| Access (Getter) – a method that is used to access or retrieve data. | true |
| Which among the following would destroy the encapsulation mechanism if it was allowed in programming? | Using access declaration for private members of base class |
| In Encapsulation, the programmer can change one part of the code without affecting other parts | true You can modify the internal implementation (like how data is stored or processed). Other parts of the program remain unaffected as long as the public interface stays the same. |
| Which statement(s) best describes an object's behavior? | Behavior acts like the verbs of an object. |
| final Class: a class that can never be sub-classed | true In Java, when a class is declared with the final keyword, it cannot be extended (sub-classed). |
| Instance Variables are variables stored in each object of a class, usually referred to as the non-static member fields of a class. | true Instance variables are non-static member fields. |
| this keyword can also be used to return the current class instance | true |
| 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 |
| The encapsulation is achieved by combining which ones into a class? | Methods and Attribute |
| If a base class is inherited in protected access mode then which among the following is true? | Public and Protected members of base class becomes protected members of derived class |
| The Scanner class contains a method called ___________ that reads user input that is a integer. | NextInt |
| An object is an instance of a: | class |
| This – contains a reference to the current object being constructed | false |
| this keyword can be passed as an argument in the method call. | true |
| this() can be used to invoke current class constructor. | true |
| Which among the following should be encapsulated? | The data prone to change in long terms |
| If class A and class B are derived from class C and class D, then ________________ | Those are 2 pairs of single inheritance |
| If multi-level inheritance is used, First class B inherits class A, then C inherits B and so on. Till how many classes can this go on? | There is no limit In multi-level inheritance, a class can inherit from another class, which in turn inherits from another, and so on. |
| ________ describes the task to be performed on objects. | OOP |
| State of an object are also known as | properties |
| OOP describes the task to be performed on objects. | true In OOP (Object-Oriented Programming), the focus is not on the task to be performed on objects, but rather on the objects themselves — their state (properties) and behavior (methods). |
| 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 | true |
| This - It represents an instance of the class in which it appears | true |
| There is an Increased security of data with Encapsulation | true |
| Which of the following is not an advantage to using inheritance? | One big superclass can be used instead of many little classes. |
| Using encapsulation data security is ___________ | Ensured to some extent |
| How many classes can be inherited by a single class in java? | Only 1 |
| Which among the following best defines single level inheritance? | A class inheriting a base class |
| Encapsulation is the way to add functions in a user defined structure. | False |
| Which among the following is true? | Java doesn't support multiple inheritance |
| Which concept of Java is achieved by combining methods and attribute into a class? | Encapsulation |
| ________ – a method that is automatically executed when an object is created. This method is used to initialize the attributes. | Constructor |
| Which programming language doesn't support multiple inheritance? | Java |
| Which concept of Java is a way of converting real world objects in terms of class? | Abstraction |
| static Method: used in defining a class method | true |
| Sally is writing some Object-Oriented Program code for a vehicle which contains the attributes (manufacturer, color, and price), along with what she wants the vehicle to be able to do (start, drive, and park). This is known as _____. | class |
| Mutator (Setter) – a method that is used to change the data. | true |
| This - It can be used to access class variables and methods. | false |
| _________– a method that is used to access or retrieve data. | Accessor (Getter) |
| dinagdag ng kupal | |
| What is it called where child object gets killed if parent object is killed? | Composition?? |
| True or False: This line of code is correct System.out.println("Hi!"); | true |
| Select correct statements about class(es). | All |
| Accessor (Getter) – a method that is used to change the data. | false |
| Select incorrect option about class Object. | You must explicitly extend class Object. |
| method variables are variables used in a method | true |
| Which amongst the following is true for hybrid inheritance? | Constructor calls are usual |
| As a blueprint is a design for a house, a class is a design for a: | object |
| What is it called if an object has its own lifecycle and there is no owner? | Association |
| If base class contains 2 nested classes, will it be possible to implement single level inheritance? | Yes, always |