• 4 hours
  • Hard

Free online content available in this course.



Got it!

Last updated on 2/21/22

Separate Application Layers Using Model-View-Controller

Log in or subscribe for free to enjoy all this course has to offer!

Evaluated skills

  • Separate Application Layers Using Model-View-Controller


The first two questions refer to the following code segment: 

private static void buildTableModel(JTable table) {
ResultSet rs = DroneDb.getResultSet("SELECT * from drones");
try {
ResultSetMetaData metaData = rs.getMetaData();
Vector<String> columnNames = new Vector<String>();
int columnCount = metaData.getColumnCount();
for (int column = 1; column <= columnCount; column++) {
// data of the table
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
while (rs.next()) {
Vector<Object> vector = new Vector<Object>();
for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
table.setModel(new DefaultTableModel(data, columnNames));
} catch (SQLException e) {
  • Question 1

    Which of the MVC layers is being addressed in the code example above?

    • Model

    • View

    • Controller

    • Calculator

  • Question 2

    In this code segment, what makes independent testing of the function difficult?

    Careful, there are several correct answers.
    • It requires the visual layer to be constructed.

    • It requires the data layer to be constructed.



    • It uses poorly named variables.

    •  The function is not difficult to test.

  • Question 3

    What is the purpose of refactoring?

    • To add a new user story to an application.

    • To fix code that has bugs/defects. 

    • To explore various architectural decisions before committing to a design.


    • To improve existing code, while maintaining the same functionality.