Exam 2 - L16 - MVC Architecture Flashcards

1
Q

What does MVC stand for and why is it important?

A

Model-View-Controller

A pattern that deparates data, UI, and input logic to improve maintainability and scalability.

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

What is the primary role of the Model in MVC?

A

It handles application data and business logic independently of the user interface.

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

What is the role of the View in MVC?

A

The view displays data from the Model and presents the UI to the user. It should not contain business logic.

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

What is the controller responsible for in MVC?

A

It processes user input, updates the Model, and refreshes the view.

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

What does “separation of concerns” mean in MVC?

A

Each component (Model, View, Controller) has a single focus, reducing coupling and making the app easier to maintain.

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

How does the Controller in Java MVC get user input?

A

It uses listeners (like ActionListener) to get data from the View and update the Model

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

What is DAO and where does it fit in MVC?

A

Data Access Object

Retrieves / stores data and belongs in the Model layer.

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

What is wrong with putting business logic in the View?

A

It violates separation of concerns, making the code harder to test and maintain

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

What principle supports MVC’s testability advantage?

A

The Single Responsibility Principle - Each component does one job and can be tested in isolation.

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

What is a Swing-based View in Java?

A

A GUI window using Java’s Swing library - e.g., JFrame, JTextField, JButton

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

What does ‘addRegisterListener()’ do in the Swing View?

A

It attaches an ‘ActionListner’ to the Register button to delegate event handling to the controller.

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

What is the role of the ‘RegisterListener’ inner class?

A

It’s a concrete ‘ActionListner’ that defines the behavior when the Register button is clicked.

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

Why should controllers be ‘lean’?

A

To keep logic clean and focused, they should delegate complex business logic to the model or services.

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

Why is MVC easier to scale?

A

You can modify or replace any layer without affecting others.

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

What is Swing in Java?

A

A GUI toolkit used to build graphical user interfaces.

Part of the Java Foundation Classes and provides components like windows, button, text fields.

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

What is AWT in Java?

A

Abstract Window Toolkit.

Java’s original GUI toolkit which provides classes for creating GUI components like buttons, windows and menus.

AWT components are heavyweight, meaning they rely on the native operating system’s GUI resources.

17
Q

How is Swing different from AWT?

A

Swing components are written in Java and rendered by Java, making them more flexible and portable than AWT components, which rely on native OS widgets.

18
Q

What is JFrame in Swing?

A

A top-level window in Swing, used to create main application windows. It supports adding GUI components like buttons and text fields.

19
Q

What is ‘JTextFiled’ in Swing?

A

A Swing component that allows users to enter a single line of text input.

20
Q

What is ‘JPasswordField’ in Swing?

A

A text input component that hides user input with bullets.

21
Q

What is ‘JButton’ in Swing?

A

A clickable button component that can trigger actions when pressed.

22
Q

What is an ‘ActionListener’ in Java?

A

A functional interface used to handle action events such as button clicks.

23
Q

How do you connect a ‘JButton’ to an ‘ActionListener’?

A

Use the method button.addActionListener(listener) to register the event handler

24
Q

Why is ‘ActionListner’ important in MVC?

A

It allows the View to delegate user actions to the Controller, preserving separation of concerns.