Viva 2.0 Flashcards
Explain what is meant by encapsulation.
Encapsulation is an OOP concept that combines similar data and functions into a single unit called a class. By doing so the data is protected from change making it easier to reuse.
Explain what is meant by inheritance.
Inheritance is the production of a new class that has been derived from an existing/base class. The derived class inherits features from the base class as well as having its own additional features.
Explain what is meant by polymorphism.
It is the ability of a function or object to perform in different ways depending on how it is used. /this is done by defining a method in a superclass but it can be overwritten by a subclass. This allows different objects to behave differently even though they are the same type.
What are templates?
A template is a generic blueprint for creating objects or functions. It can be used to create different types of objects or functions without having to rewrite the code for each type. This can save time and effort for making programs more efficient.
Explain the procedure you would follow to obtain a copy of an online Git repository, make some changes, and then update the online repository with your changes.
First you would git clone the online repository with the git repo URL, then make your changes to the file. Then you would add . and commit with a message. Finally you would git push which pushes all your changes to the online repo.
What is a fork on Git, how do you create a fork and obtain a local copy of the fork?
A fork on Git is a copy of a repository that is owned by another user. Forking a repository allows you to make changes to the code without affecting the original repository. You can then create a pull request to merge your changes back into the original repository. To create a fork, you can click the fork button on the GitHub repository you want to fork, this will be created in your GitHub account and a local copy of this fork can be obtained by using git clone followed by URL.
What are Github actions and how can they be used?
Github actions is a feature that allow users to automate, customise and execute workflows based on predefined events. Some examples of their usage are issues and pull request management, publish packages or in our case the doxygen pages build and deployment.
What is the difference between and pull and a fetch operation in Git?
Git fetch only downloads new changes from the remote repo and leaves you to manually merge them, whereas git pull downloads all new changes and auto merges them with your local branch. Git pull is just the two commands git fetch and git merged combined into one.
Explain the differences between static and dynamic libraries.
Static libraries are compiled into the executable file at compile time and are easier to distribute but make larger executable files. Dynamic libraries on the other hand are linked to the program at runtime .This mean that the code from the dynamic library is not merged with the code from the program but is instead loaded into memory when the program is run. Dynamic libraries are typically used for code that is expected to change frequently, as updating a dynamic library does not require recompiling the program.
Describe the steps involved in building a program using command line compiler tools.
install the compiler for the programming language that you want to use
create a directory to store your project files. This directory will contain your source code files, as well as any other files that are needed to build the program.
write your source code. The source code is the text that tells the compiler how to build your program.
compile it.
Next, the object files are linked. Object files are the compiled versions of the source code. Linking them combines the object files into a single executable file.
Lastly you can now run the program by typing the name of the executable file at the command prompt.
Explain how user actions, such as the click of a button, can be linked to useful code in a Qt application.
- Qt uses a signal and slot mechanism to establish connections between the user interface elements, and the code that handles their actions.
1) A signal is first emitted by an object to indicate that an event or action has occurred. For example, a QPushButton object emits a signal called ‘clicked()’ when it is clicked.
2) A slot function then gets executed in response to that signal. You must define slots in your code that correspond to the different signals.
3) Next the signals and slots are linked by using the ‘connect()’ function.
4) Once the signals and slots are connected, then the event loop detects this signal and triggers the connected slot, allowing associated code to execute.
You have created a Qt application with a GUI that was designed in Qt designer, the GUI contains a checkbox. How might you determine the state of the checkbox from within the C++ code of your application
1) First is to assign an object name to the checkbox
2) next is to then access the checkbox in the C++ code by using the ‘findChild()’ functions, which searches for a child widget with the specified object name within a parent widget.
3) Then you can write an if statement to see if the checkbox is checked by using the ‘isChecked()’ function.
You have an application with a Qt based GUI that includes toolbars and menus with icons. How might these icons be stored/accessed by the application when it runs?
There are two ways to store/access these icons when the application is run.
The first is using the resource files. Qt provides a resource system that allows you to bundle icons, and other resources, directly into the application executable. The icons can be accessed at runtime using the resource system’s prefix notation and ‘QIcon icon()’.
The second is by loading the files externally. The icons can be stored as separate files on the disk, still using the same ‘QIcon icon()’ function to load them up at runtime using their file paths.
An application linked with Qt compiles without any errors or warnings but when you try to run it from within Visual Studio it will not launch. Why might this be?
1) missing or incorrect DLLs (Dynamic link libraries).
3) Qt applications may also require additional resources or files to run correctly.
4) There might be issues with the runtime environment, such as missing system dependencies or conflicting settings, that prevent the application from running.
What VTK classes must be used to render a simple object, e.g. a cube, in an application?
To create a cube, you’ll need vtkCubeSource, the class to create a cube, vtkPolyDataMapper, a class which maps a vtkPolyData object to a graphics primitive, vtkActor, a class that represents an actor in the scene, vtkRenderer, a class that represents a 3D rendering window, and vtkRenderWindowInteractor, a class that allows the user to interact with the rendered scene.