Java Interview Guide : 200+ Interview Questions and Answers - What is Cohesion?

Java Interview Guide : 200+ Interview Questions and Answers - What is Cohesion?

Assessment

Interactive Video

Information Technology (IT), Architecture

University

Hard

Created by

Wayground Content

FREE Resource

The video discusses the concept of cohesion in software design, emphasizing the importance of having highly cohesive classes where responsibilities are closely related. An example of a class with low cohesion is analyzed, highlighting its multiple unrelated responsibilities. The video then proposes a solution by dividing responsibilities into separate classes, each handling a specific task, such as downloading, parsing, and storing data. This approach leads to better cohesion and more maintainable code. The video concludes by discussing how organizing classes in this manner results in highly cohesive applications.

Read more

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does cohesion in a class refer to?

How related the responsibilities of a class are

The speed at which a class executes

The amount of data a class can handle

The number of methods in a class

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Why is the 'download and store' class considered to have low cohesion?

It is too complex to understand

It has too few methods

It uses too many external libraries

It handles multiple unrelated responsibilities

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is NOT a responsibility of the 'download and store' class?

Storing data into a database

Parsing data

Rendering data on a webpage

Downloading data from the Internet

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can cohesion be improved in the 'download and store' example?

By reducing the number of lines of code

By splitting responsibilities into separate classes

By adding more methods to the class

By using a different programming language

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main responsibility of the 'Internet downloader' class?

Rendering data on a webpage

Downloading data from the Internet

Storing data into a database

Parsing data

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the benefit of having a 'database storer' class?

It can handle multiple types of databases

It focuses solely on storing data into a database

It can parse and store data simultaneously

It reduces the need for a database

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the role of the 'download and store' class in a high cohesion design?

To parse data from the Internet

To directly interact with the database

To create instances of other classes and coordinate their actions

To handle all responsibilities related to data processing