Lecture 1 Flashcards

1
Q

What is structure programming

A

Structured programming (SP) is a technique that was devised to improve the reliability and clarity of programs.

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

In SP control of program flow is restricted to?

A

In Structured programming (SP) control of program flow is restricted to three structures, sequence, selection and iteration.

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

What is modular programming

A

Modular programming is a general programming concept that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality

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

What do you mean by code is easier to read for modular programming

A

Modular programming involves breaking down code into smaller functions, each handling a specific aspect of the overall functionality.

This approach enhances readability by organizing code into manageable units

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

Why moular programming?

A

Code is easier to read
Code is easier to test
Reusability
Easier to collaborate

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

What do you mean code is easier to test

A

Software that’s split into distinct modules is also ideal for testing.

That’s because tests can be much
stricter and more detailed when you test small functions that do less, compared to big functions that do a number of things.

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

Why is code more reusable in modular programming

A

Modularity in programming prevents redundant code by centralizing common functions or code snippets in a single source, facilitating reuse across different sections of a program.

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

Why is it easier to collaborate

A

Modular programming is essential where multiple teams need to work on different components of a program

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

Why do people still write spaghetti code

A
  1. Code size: Modularity can increase code size and impact performance if you can’t tree shake your dependencies
  2. Complexity - Sometimes complex file systems aren’t necessary and can add unnecessary overhead
  3. Security - Monolithic code can make it harder for people to mess with code that the original developer doesn’t want changed, hacked, or pirated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is stepwise refinement

A

Stepwise Refinement is the process of breaking down a programming problem into a series of steps.

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

What is Object Oriented Programming

A

Object-Oriented Programming (OOP) is a way of writing code that focuses on creating “objects” which contain both data (like information about a person) and the functions, or actions, that can be performed with that data (like making the person walk or talk).

It helps organize code better and makes it easier to work with, especially in larger projects.

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

What is a class?

A

In programming, a class is like a blueprint or a template for creating objects.

It defines the properties (attributes or variables) and behaviors (methods or functions) that all objects of that class will have.

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

What are attributes

A

Attributes are the individual things that differentiate one object from another and determine the appearance, state, or other qualities of that object.

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

What is a behaviour of a class

A

In programming, a behavior refers to the actions or functions that an object can perform. In the context of object-oriented programming (OOP), behaviors are typically defined as methods within a class

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

What is a constructor

A

A constructor is a special member function in a class that is automatically called when an object of that class is created.

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

Describe Encapsulation

A

OOP provides the ability to encapsulate data and behavior into a single unit called an object.

16
Q

Describe Polymorphism

A

Polymorphism is an object-oriented programming concept that refers to the ability of an object to take on multiple forms.

17
Q

Describe Abstraction

A

Abstraction allows you to represent complex real-world objects in a simplified manner.

18
Q

What is message passing

A

Message passing is the sending of a message from one object to another.

19
Q

Describe Inherintance

A

Inheritance: Inheritance is a mechanism that allows a new class to be based on an existing class.

20
Q

Mention 5 types inherintance

A

Single inheritance
Multiple inheritance
Multilevel inheritance
Hierarchical inheritance
Hybrid Inheritance

21
Q

Describe Single Inherintance

A

Single inheritance: Single inheritance is a type of inheritance in which a subclass inherits from a single superclass.

22
Q

Describe Multiple inherintance

A

Multiple inheritance: Multiple inheritance is a type of inheritance in which a subclass inherits from multiple super classes.

23
Q

Describe Multilevel Inherintance

A

Multilevel inheritance: Multilevel inheritance is a type of inheritance in which a subclass inherits from a superclass, which in turn inherits from another superclass.

24
Q

Describe hierarchical

A

Hierarchical inheritance: Hierarchical inheritance is a type of inheritance in which a single superclass is inherited by multiple subclasses.

25
Q

Describe hybrid inherintance

A

Hybrid Inheritance: Hybrid inheritance is a combination of more than two types of inheritances single and multiple.

26
Q

What is Access Modifiers

A

Access modifiers are keywords that control the visibility of class members

27
Q

How many types of access modifiers

A

Public
Default – No keyword required
Protected
Private

28
Q

Describe public access modifier

A

A public class, method, or variable can be accessed from anywhere in the program. It has the highest level of accessibility.

29
Q

Describe default access modifier

A

A default class, method, or variable can be accessed within the same package, but not outside of it.

30
Q

Describe protected

A

A protected class, method, or variable can be accessed within the same package and subclasses of the class in any package.

31
Q

Describe private

A

A private class, method, or variable can only be accessed within the same class. It has the lowest level of accessibility.

32
Q

What is an interface

A

An Interface in Java programming language is defined as an abstract type used to specify the behavior of a class.
An interface in Java is a blueprint of a class.

33
Q

A java interface contains

A

A Java interface contains static constants and abstract methods.

34
Q

An interface tries to achieve

A

Abstraction

35
Q

What are packages

A

Packages in Java are a way of grouping together related classes and interfaces.

36
Q

What is JFrame

A

JFrame is a top-level container that represents the main window of a Java Swing application.

It provides the basic framework for the application’s user interface, including the title bar, window decorations, and the main content area where other components can be added.

37
Q

What is JPanel

A

JPanel is a container that can be added to a JFrame or another JPanel. It provides a way to organize and group together other components such as buttons, labels, text fields, and more

38
Q

What is JButton

A