Basic programming Flashcards Preview

Infosys prep > Basic programming > Flashcards

Flashcards in Basic programming Deck (56)
Loading flashcards...
1
Q

What are the four pillars of OOP?

A
  1. Data encapsulation
  2. Data abstraction
  3. Inheritance
  4. Polymorphism

EAIP –> every apple is perfect

2
Q

What is an object?

A

The physical presence of the class in memory

3
Q

What is a class?

A

The blueprint from which objects are created. The class defines the different properties of a type of object

4
Q

What is a method?

A

A block of code that performs some type of action on an object

5
Q

What is an instance?

A

A unique reference (copy) of an object

6
Q

What is data encapsulation?

A

Combining both data and methods into a class definition. It helps with hiding this data from the outside world as the scope will be limited to just that specific class. It means that only objects of that class have access to those specific private methods. We can also define public methods which can be called by other classes. (Dog example)

7
Q

What is data abstraction?

A

Abstraction is an extension of encapsulation. It is the process of taking specific, required data from a larger pool of data. You may not always need all of the data that is available to you so you can choose to select and retrieve only the data that you need at that time - use example

8
Q

What is inheritance?

A

Allowing one object access to some or all of the properties of another object - this process keeps your code DRY and prevents repetition. Example - classes for different buildings e.g. shop, house, hospital – instead of adding width, height, material, etc. properties to all of these classes, you could create a building class that these types of building would inherit from

9
Q

What is polymorphism?

A

Directly translates to something that takes on many forms. It’s a method that lets us call the same method on different classes. E.g. different vehicle classes - car, truck. Can add the same method to both of these classes that spits out the type of vehicle it is –> the same class can therefore be called on different types of class to give different results.

10
Q

What is SDLC?

A

Software Development Life Cycle. Refers to the end-to-end process of developing software. Stages include:

  1. Planning
  2. Analysis
  3. Design
  4. Development
  5. Testing/integration/QA
  6. Maintenance
  7. Optimisation
11
Q

What are the disadvantages of the waterfall model?

A
  1. Working software is produced only at the end of the cycle
  2. Not suitable for complex projects
  3. Difficult to measure progress within each stage
  4. Not recommended for projects that may have frequently changing priorities
12
Q

What is the waterfall method?

A

A method of software development where the process takes place in a linear, sequential flow - each phase must be completed before the next phase can be started.

13
Q

What are the advantages of the waterfall model?

A
  1. Simple and easy to understand
  2. Everything is well documented and planned out
  3. Works well for smaller projects where requirements are very well understood.
  4. Phases are clearly defined
  5. Well understood milestones
14
Q

What is the agile model?

A

Agile has an iterative approach that allows teams to deliver value to their customers faster than if they followed the waterfall model. The product will be delivered in smaller chunks rather than being held off and delivered in its entirety at the end. Teams can quickly respond to change as testing is continually taking place.

Scrum and Kanban are the most used Agile methodologies

15
Q

What is a frame in HTML?

A

HTML Frames are useful for dividing browser windows into many parts where each section is able to load an HTML document separately.

It permits authors to present HTML documents in multiple views, which might be subwindows or independent windows. Multiple views provide help to keep specific information visible, while other views are replaced or scrollable.

16
Q

Explain white box vs black box testing

A
  • white box - tester has complete knowledge of how the app works, done by devs and QA specialists, more time consuming and exhaustive
  • black box - not necessary to know exactly how the app works, done by end user but also by devs and QAs, done based on an end user perspective, less time consuming and exhaustive
17
Q

Explain different levels of programming languages.

A

Low - the language that is understood by the machine - binary/machine language. Humans tend not to interact with it

Assembly - similar to machine language but uses words instead of numbers

Mid - serve as a bridge between the hardware and programming layer of a computer e.g. C

High - has strong abstraction from the computer hardware details. Most simple to learn by humans e.g. python, ruby

18
Q

What is a variable?

A

Variables hold data which can be reused over and over again. The place of their definition determines their scope

19
Q

What would be the answer to 6+1+”7”?

A

Type error as a string can’t be added to an integer without prior conversion

20
Q

What is MVC?

A

MVC –> Model, View, Controller

MVC is an architectural pattern which consists of the models, views and controllers and it’s used in designing mobile apps and web apps. It’s used by frameworks such as Ruby on Rails. Each component of MVC has different responsibilities:

Model - the model handles the data and is connected to the database. Handles data validation, specifies the relationships between tables. Responds to controller requests.

View - controls the UI. HTML/CSS are managed here. This is what the user sees. The view speaks to the controller to ask it to retrieve the necessary data from the model.

Controller - the brains behind the operation. Responsible for speaking to the other components. Controller tells the model what to do and then processes data before sending it on to the view for the view to display to the user.

Benefits: provides a solid structure to our web app and means we don’t have to repeat ourselves. Separates UI from business logic. Easy to maintain.

Disadvantages: can be too complex for small apps.

21
Q

What is routing in MVC?

A

A pattern matching system that is responsible for mapping incoming browser requests to specified controller actions. If there is no matching route then the browser will display a 404 error. Else it will direct the user to the correct page

22
Q

Authentication and Authorisation in Web API

A

Authentication (devise - gem) is the process of verifying who someone is, whereas authorisation (pundit) is the process of verifying what specific applications, files, and data a user has access to.

23
Q

SOLID principle

A

SOLID is a mnemonic acronym for five design principles intended to make software designs more understandable, flexible, and maintainable. https://medium.com/backticks-tildes/the-s-o-l-i-d-principles-in-pictures-b34ce2f1e898. Taking the example of a class (but same applies to variables, methods, etc.)

-Single responsibility
If a class has more than 1 responsibility then you're increasing the likelyhood of bugs - changing one responsibility might affect the others 
-Open-closed
Classes should be open for extension but closed for modification. Changing the current behaviour of a class will affect all of the systems using that class

-Liskov-substitution
If S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program. The child Class should be able to do everything the parent Class can do. This process is called Inheritance.

-Interface segregation
Clients should not be forced to depend on methods that they do not use. Classes should not have to perform actions that are not useful.

-Dependency inversion
This principle says a Class should not be fused with the tool it uses to execute an action. Rather, it should be fused to the interface that will allow the tool to connect to the Class.
It also says that both the Class and the interface should not know how the tool works. However, the tool needs to meet the specification of the interface. –>

  • High-level Module(or Class): Class that executes an action with a tool.
  • Low-level Module (or Class): The tool that is needed to execute the action
  • Abstraction: Represents an interface that connects the two Classes.
  • Details: How the tool works
24
Q

What is an API?

A

Application Programming Interface.
It’s the software that allows two applications to communicate with each other. E.g. the Facebook API is what allows the facebook app on your phone to communicate with the FB servers so that the app can function

25
Q

How does the internet work?

A
26
Q

What is the job of the controller?

A

The controller is the brains in an MVC architecture.

It communicates with the model and the view because they don’t directly communicate with each other. It tells the model what data is required and then processes and passes this data on to the view to display it to the user.

27
Q

How can you deploy your code?

A

You can use Git to deploy to Heroku which can be used to host the website. Git push heroku master.

28
Q

What is version control?

A

A process of tracking and managing changes to the code. It makes it possible for multiple developers to work on the same codebase. Git is a version control software

29
Q

What does JRE mean?

A

Java runtime environment. It is a set of components to create and run a Java application

30
Q

What is Java?

A

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.

31
Q

What is arp tcp header

A

ARP = address resolution protocol

32
Q

What is the difference between C and C++ and C#

A

C is the oldest. It’s a low level language that performs almost as efficiently as assembly code. It’s not an OO language. Data and functions are “free entities,” which means you can manipulate them with outside code.

C++ and C# are extensions of C.

C++ is an intermediate level language with OOP capabilities.

C# is a high level OOP language

As object-oriented languages, C++ and C# support polymorphism, encapsulation, and inheritance, while C does not. Since C++ and C# encapsulate data and functions together into a single object, those data structures and operators are hidden to outside code.

33
Q

What is let and const in JS?

A

Two different ways to declare a variable. Let should be used to declare a variable whose definition might change, const should be used when the variable will always remain unchanged.

34
Q

What are some different data structures?

A

Arrays, hashes

35
Q

What are the different data types?

A

Integer, boolean, string, float

36
Q

What is the difference between == and === in JS?

A

== is a comparison which also converts data types. So, if you compare a string with a number, then the string will be converted to a number and then compared

=== is a strict comparison which does not convert to a different data type. So if you compare a string and a number then the result will be false.

37
Q

What is isNaN() and what does it return?

A

it’s a function that tells you if something is or is not a number

38
Q

What is super()?

A

The super keyword in JavaScript acts as a reference variable to the parent class. It is mainly used when we want to access a variable, method, or constructor in the base class from the derived class.

39
Q

What is a constructor function?

A

Constructor functions are templates for creating objects.

40
Q

What are the different loops?

A

simple loop, for loop, while loop, until loop, iteration

41
Q

Can a constant variable be changed?

A

Yes, properties and methods be changed for a const object.

A const declaration does not mean that the value of the variable cannot be changed. It just means that the variable identifier cannot be reassigned.

42
Q

What is a dictionary?

A

Dictionaries provide one key and one value matched together.

43
Q

What is bootstrap used for?

A

Bootstrap is a free and open-source CSS framework directed at responsive, mobile-first front-end web development. It contains CSS and (optionally) JavaScript-based design templates for typography, forms, buttons, navigation, and other interface components

44
Q

How do you use the grid system in bootstrap?

A

Bootstrap’s grid system uses a series of containers, rows, and columns to layout and align content. It’s built with flexbox and is fully responsive

45
Q

What do you use a container for in bootstrap?

A

Containers are the most basic layout element in Bootstrap and are required when using our default grid system. Containers are used to contain, pad, and (sometimes) center the content within them

46
Q

Have you used any web frameworks?

A

Yes, Ruby on Rails. It’s based around the MVC architecture

47
Q

Do you have to state the variable type when you define it in Ruby?

A

No

48
Q

What is the relationship between an object and a class?

A

an object is an element (or instance) of a class; objects have the behaviors of their class. The object is the actual component of programs, while the class specifies how instances are created and how they behave

49
Q

What is version control?

A

the practice of tracking and managing changes to software code.

e.g. using git

50
Q

Name some common tags used in HTML.

A

html, head, body, div, strong, span, button, ul, ol, title, h1, h2…, a, br, table

51
Q

What is the difference between compile-time and run time?

A

Compile time is the period when the programming code (such as C#, Java, C, Python) is converted to the machine code (i.e. binary code).

Runtime is the period of time when a program is running and generally occurs after compile time.

52
Q

What is an interface?

A

In general, an interface is a device or a system that unrelated entities use to interact

53
Q

What is Ruby on Rails?

A

An open-source web application development framework written in the Ruby. It’s one of the most popular Ruby libraries.

Modern web applications can be very complex with many layers. Rails makes web development easier, providing a pre-built structure for development and everything you need to build a web app.

A framework simplifies the creation of web applications. It does this by providing default structures for your code, any databases you use, and the web pages the application will serve.

You can think of a framework almost like Legos. With a framework, you get pre-built “Legos” of code that you can mix, match, and modify to build a custom web application, which means you don’t have to create everything from scratch.

Ruby on Rails uses the Model-View-Controller (MVC) architectural pattern used by many other web frameworks — one of the most well-known patterns in development.

54
Q

What is a scrum meeting?

A

A scrum meeting is a catch all term that covers all types of meetings that happen in scrum teams. They can include daily stand ups, sprint planning sessions and retrospectives.

55
Q

What is the spiral model?

A

The spiral model is a risk-driven software development process model. It contains four phases; Planning, Risk Analysis, Engineering and Evaluation. A software project repeatedly passes through these phases in iterations (called Spirals in this model). The spiral model places a lot of emphasis on risk analysis

56
Q

What’s the difference between git and github?

A

Git is a version control system that lets you manage and keep track of your source code history. GitHub is a cloud-based hosting service that lets you manage Git repositories