op Flashcards

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
Q

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

A

preventing

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

Which of the following is FALSE about abstract classes in Java

A

A class can be made abstract without any abstract method

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

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.

A

Reusability

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

Which statement is true?

A

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
Q

In Java programming language, the code is placed inside ___.

A

All the above

30
Q

Final methods can…

A

Not be overridden

31
Q

final keyword is only for constants

32
Q

__________ inheritance is achieved using interface in java

33
Q

It is possible to override private or static methods in Java

34
Q

All the variables of class should be ideally declared as?

35
Q

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

A

Preventing

36
Q

Which of the following OOP concept binds the code and data together and keeps them secure from the outside world?

A

Encapsulation

37
Q

Which of these class is superclass of every class in Java?

A

Object class

38
Q

What is an Encapsulation?

A

a mechanism of wrapping the data (variables) and code acting on that data (methods) together as a single unit.

39
Q

What is a class?

A

a prototype that consists of objects in different states and with different behaviors.

40
Q

Which of the statements are correct for Interfaces?

A

All of the statements

41
Q

Parts of the classes

A

Constructors, Methods, Fields

42
Q

Which of the statements are incorrect for Interfaces?

A

We can create objects of an interface

43
Q

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

44
Q

What does the modifier protected mean?

A

accessible in the same package and by subclasses

45
Q

What is inheritance?

A

a feature of OOPs which allows classes inherit common properties from other classes.

46
Q

Which concept of Java is a way of converting real world objects in terms of class?

A

Abstraction

47
Q

Which of these keywords can be used to prevent inheritance of a class?

48
Q

An abstract class normally contains one abstract methods

49
Q

An object is an entity which has bundles of properties and methods can interact with other objects.

A

Reusability

50
Q

Which of the following is FALSE about abstract classes in Java

A

A class can inherit from multiple abstract classes.

51
Q

What is the catch statement?

A

allows you to define a block of code to be tested for errors while it is being executed.

52
Q

What does the Liskov’s Substitution principle mean?

A

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
Q

Which of the following statements correct for Lambda Expression?

A

All of the statements

54
Q

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”);} }

55
Q

What does the Dependency Inversion principle mean?

A

you make sure that your class or module has high cohesion, which means that your class does not do more than it should

56
Q

Which of the following statements is correct for OCP?

A

Objects or entities should be open for extension, but closed for modification

57
Q

For which principle does this statement apply “It should be possible to change an implementation easily without altering high level code”?

58
Q

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

59
Q

System generated exceptions are manually thrown by the Java run time system

60
Q

Which of the following statements is not correct for ISP?

A

A client should never depend on anything more that the method which is used

61
Q

What is exception handling?

A

is a very important concept that is used to manage errors.

62
Q

How many steps we have to connect DB?

63
Q

Exception handling enables applications to __________ exceptions

64
Q

For which principle does this statement apply “A class should have only one reason to change”?

65
Q

Use throw keyword to manually throw an exception

66
Q

Which of the following statements is not correct for OCP?

A

Changing a method should not affect on unrelated class

67
Q

Structure of the Lambda expression.

A

(parameterList) -> {statements}

68
Q

The statement which allows to create a custom error.

69
Q

What does the Interface Segregation principle mean?

A

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.