op Flashcards
Which of these is correct way of inheriting class A by class B?
class B extends A {}
In java, __________ keyword is used to derive from another class
extends
Which class cannot create its instance?
Abstract class
Which of these method of ArrayList class is used to obtain present size of an object?
size()
How many interfaces can a class implement?
As many as needed
What does an interface contain?
Method declaration
All the variables of class should be ideally declared as?
private
How can the concept of encapsulation be achieved in the program?
By using the Access specifiers
______________ is similar to a method but it is called implicitly by the new operator to initialize an object’s instance variables when the object is created
Constructor
You can extend the class and create a totally new class that retains all the necessary properties and methods of the parent class from which it has been derived, and then expose new features.
.
Extensibility
__________ inheritance is achieved using interface in java
Multiple
Which concept of Java is achieved by combining methods and attribute into a class?
Encapsulation
Which among the following is correct?
class student{ public: student(){} };
Method overriding is combination of inheritance and polymorphism?
true
Which of the following is NOT an OOPS concept in Java?
Compilation
All classes inherit the cosmic superclass
T
true
Getters and setters are ___________ methods which are used if there is a need to provide an indirect access to private fields.
public
What is a superclass?
a class that acts as a parent to some other class or classes
It is possible to override private or static methods in Java
False
Which of the following statements are incorrect?
private members of class can be inherited by a subclass, and become protected members in subclass
Polymorphism in Java is of two types, namely ______ and __________
Run time, Compile time
Which feature of OOP indicates code reusability?
Inheritance
Which of these class relies upon its subclasses for complete implementation of its methods?
abstract class
All classes defined without an explicit extends clause automatically extend ___________
Object
Data hiding is one of the important features of Object Oriented Programming which allows ___________ the functions of a program to access directly the internal representation (or state of an object) of a class type
preventing
Which of the following is FALSE about abstract classes in Java
A class can be made abstract without any abstract method
When you need to refactor your projects, OOP gives you the maximum benefit because all objects are small entities and contain its properties and methods as a part of itself.
Reusability
Which statement is true?
1.An interface can sub interfaced from other interface
2.Interface support extending
3.Interface can’t support extending
d.
4.Both 1 and 2
In Java programming language, the code is placed inside ___.
All the above
Final methods can…
Not be overridden
final keyword is only for constants
False
__________ inheritance is achieved using interface in java
multiple
It is possible to override private or static methods in Java
False
All the variables of class should be ideally declared as?
Private
Data hiding is one of the important features of Object Oriented Programming which allows ___________ the functions of a program to access directly the internal representation (or state of an object) of a class type
Preventing
Which of the following OOP concept binds the code and data together and keeps them secure from the outside world?
Encapsulation
Which of these class is superclass of every class in Java?
Object class
What is an Encapsulation?
a mechanism of wrapping the data (variables) and code acting on that data (methods) together as a single unit.
What is a class?
a prototype that consists of objects in different states and with different behaviors.
Which of the statements are correct for Interfaces?
All of the statements
Parts of the classes
Constructors, Methods, Fields
Which of the statements are incorrect for Interfaces?
We can create objects of an interface
Which of these method of ArrayList class is used to obtain present size of an object?
size()
What does the modifier protected mean?
accessible in the same package and by subclasses
What is inheritance?
a feature of OOPs which allows classes inherit common properties from other classes.
Which concept of Java is a way of converting real world objects in terms of class?
Abstraction
Which of these keywords can be used to prevent inheritance of a class?
final
An abstract class normally contains one abstract methods
False
An object is an entity which has bundles of properties and methods can interact with other objects.
Reusability
Which of the following is FALSE about abstract classes in Java
A class can inherit from multiple abstract classes.
What is the catch statement?
allows you to define a block of code to be tested for errors while it is being executed.
What does the Liskov’s Substitution principle mean?
to build software systems from interchangeable parts, those parts must adhere to a contract that allows those parts to be substituted one for another.
Which of the following statements correct for Lambda Expression?
All of the statements
What will be the output in below code? public class Demo{ public static void main(String[] arr){ System.out.println(“Main1”); } public static void main(String arr){ System.out.println(“Main2”);} }
Main1
What does the Dependency Inversion principle mean?
you make sure that your class or module has high cohesion, which means that your class does not do more than it should
Which of the following statements is correct for OCP?
Objects or entities should be open for extension, but closed for modification
For which principle does this statement apply “It should be possible to change an implementation easily without altering high level code”?
DIP
Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods, or with a single class declaration, a set of related types, respectively
True
System generated exceptions are manually thrown by the Java run time system
False
Which of the following statements is not correct for ISP?
A client should never depend on anything more that the method which is used
What is exception handling?
is a very important concept that is used to manage errors.
How many steps we have to connect DB?
6
Exception handling enables applications to __________ exceptions
Handle
For which principle does this statement apply “A class should have only one reason to change”?
SRP
Use throw keyword to manually throw an exception
True
Which of the following statements is not correct for OCP?
Changing a method should not affect on unrelated class
Structure of the Lambda expression.
(parameterList) -> {statements}
The statement which allows to create a custom error.
throw
What does the Interface Segregation principle mean?
A client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use.