Lecture 1 Flashcards
What is structure programming
Structured programming (SP) is a technique that was devised to improve the reliability and clarity of programs.
In SP control of program flow is restricted to?
In Structured programming (SP) control of program flow is restricted to three structures, sequence, selection and iteration.
What is modular programming
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
What do you mean by code is easier to read for modular programming
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
Why moular programming?
Code is easier to read
Code is easier to test
Reusability
Easier to collaborate
What do you mean code is easier to test
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.
Why is code more reusable in modular programming
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.
Why is it easier to collaborate
Modular programming is essential where multiple teams need to work on different components of a program
Why do people still write spaghetti code
- Code size: Modularity can increase code size and impact performance if you can’t tree shake your dependencies
- Complexity - Sometimes complex file systems aren’t necessary and can add unnecessary overhead
- Security - Monolithic code can make it harder for people to mess with code that the original developer doesn’t want changed, hacked, or pirated
What is stepwise refinement
Stepwise Refinement is the process of breaking down a programming problem into a series of steps.
What is Object Oriented Programming
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.
What is a class?
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.
What are attributes
Attributes are the individual things that differentiate one object from another and determine the appearance, state, or other qualities of that object.
What is a behaviour of a class
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
What is a constructor
A constructor is a special member function in a class that is automatically called when an object of that class is created.
Describe Encapsulation
OOP provides the ability to encapsulate data and behavior into a single unit called an object.
Describe Polymorphism
Polymorphism is an object-oriented programming concept that refers to the ability of an object to take on multiple forms.
Describe Abstraction
Abstraction allows you to represent complex real-world objects in a simplified manner.
What is message passing
Message passing is the sending of a message from one object to another.
Describe Inherintance
Inheritance: Inheritance is a mechanism that allows a new class to be based on an existing class.
Mention 5 types inherintance
Single inheritance
Multiple inheritance
Multilevel inheritance
Hierarchical inheritance
Hybrid Inheritance
Describe Single Inherintance
Single inheritance: Single inheritance is a type of inheritance in which a subclass inherits from a single superclass.
Describe Multiple inherintance
Multiple inheritance: Multiple inheritance is a type of inheritance in which a subclass inherits from multiple super classes.
Describe Multilevel Inherintance
Multilevel inheritance: Multilevel inheritance is a type of inheritance in which a subclass inherits from a superclass, which in turn inherits from another superclass.
Describe hierarchical
Hierarchical inheritance: Hierarchical inheritance is a type of inheritance in which a single superclass is inherited by multiple subclasses.
Describe hybrid inherintance
Hybrid Inheritance: Hybrid inheritance is a combination of more than two types of inheritances single and multiple.
What is Access Modifiers
Access modifiers are keywords that control the visibility of class members
How many types of access modifiers
Public
Default – No keyword required
Protected
Private
Describe public access modifier
A public class, method, or variable can be accessed from anywhere in the program. It has the highest level of accessibility.
Describe default access modifier
A default class, method, or variable can be accessed within the same package, but not outside of it.
Describe protected
A protected class, method, or variable can be accessed within the same package and subclasses of the class in any package.
Describe private
A private class, method, or variable can only be accessed within the same class. It has the lowest level of accessibility.
What is an interface
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.
A java interface contains
A Java interface contains static constants and abstract methods.
An interface tries to achieve
Abstraction
What are packages
Packages in Java are a way of grouping together related classes and interfaces.
What is JFrame
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.
What is JPanel
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
What is JButton