op Flashcards

(69 cards)

1
Q

Which of these is correct way of inheriting class A by class B?

A

class B extends A {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In java, __________ keyword is used to derive from another class

A

extends

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which class cannot create its instance?

A

Abstract class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of these method of ArrayList class is used to obtain present size of an object?

A

size()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many interfaces can a class implement?

A

As many as needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does an interface contain?

A

Method declaration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

All the variables of class should be ideally declared as?

A

private

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can the concept of encapsulation be achieved in the program?

A

By using the Access specifiers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

______________ 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

A

Constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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.
.

A

Extensibility

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

__________ inheritance is achieved using interface in java

A

Multiple

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which concept of Java is achieved by combining methods and attribute into a class?

A

Encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which among the following is correct?

A

class student{ public: student(){} };

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Method overriding is combination of inheritance and polymorphism?

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which of the following is NOT an OOPS concept in Java?

A

Compilation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

All classes inherit the cosmic superclass

T

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Getters and setters are ___________ methods which are used if there is a need to provide an indirect access to private fields.

A

public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a superclass?

A

a class that acts as a parent to some other class or classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

It is possible to override private or static methods in Java

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Which of the following statements are incorrect?

A

private members of class can be inherited by a subclass, and become protected members in subclass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Polymorphism in Java is of two types, namely ______ and __________

A

Run time, Compile time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Which feature of OOP indicates code reusability?

A

Inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Which of these class relies upon its subclasses for complete implementation of its methods?

A

abstract class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

All classes defined without an explicit extends clause automatically extend ___________

A

Object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
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
26
Which of the following is FALSE about abstract classes in Java
A class can be made abstract without any abstract method
27
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
28
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
29
In Java programming language, the code is placed inside ___.
All the above
30
Final methods can...
Not be overridden
31
final keyword is only for constants
False
32
__________ inheritance is achieved using interface in java
multiple
33
It is possible to override private or static methods in Java
False
34
All the variables of class should be ideally declared as?
Private
35
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
36
Which of the following OOP concept binds the code and data together and keeps them secure from the outside world?
Encapsulation
37
Which of these class is superclass of every class in Java?
Object class
38
What is an Encapsulation?
a mechanism of wrapping the data (variables) and code acting on that data (methods) together as a single unit.
39
What is a class?
a prototype that consists of objects in different states and with different behaviors.
40
Which of the statements are correct for Interfaces?
All of the statements
41
Parts of the classes
Constructors, Methods, Fields
42
Which of the statements are incorrect for Interfaces?
We can create objects of an interface
43
Which of these method of ArrayList class is used to obtain present size of an object?
size()
44
What does the modifier protected mean?
accessible in the same package and by subclasses
45
What is inheritance?
a feature of OOPs which allows classes inherit common properties from other classes.
46
Which concept of Java is a way of converting real world objects in terms of class?
Abstraction
47
Which of these keywords can be used to prevent inheritance of a class?
final
48
An abstract class normally contains one abstract methods
False
49
An object is an entity which has bundles of properties and methods can interact with other objects.
Reusability
50
Which of the following is FALSE about abstract classes in Java
A class can inherit from multiple abstract classes.
51
What is the catch statement?
allows you to define a block of code to be tested for errors while it is being executed.
52
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.
53
Which of the following statements correct for Lambda Expression?
All of the statements
54
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
55
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
56
Which of the following statements is correct for OCP?
Objects or entities should be open for extension, but closed for modification
57
For which principle does this statement apply "It should be possible to change an implementation easily without altering high level code"?
DIP
58
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
59
System generated exceptions are manually thrown by the Java run time system
False
60
Which of the following statements is not correct for ISP?
A client should never depend on anything more that the method which is used
61
What is exception handling?
is a very important concept that is used to manage errors.
62
How many steps we have to connect DB?
6
63
Exception handling enables applications to __________ exceptions
Handle
64
For which principle does this statement apply "A class should have only one reason to change"?
SRP
65
Use throw keyword to manually throw an exception
True​
66
Which of the following statements is not correct for OCP?
Changing a method should not affect on unrelated class
67
Structure of the Lambda expression.
(parameterList) -> {statements}
68
The statement which allows to create a custom error.
throw
69
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.