Risk Management. I.T. Mock Interview Correction

Similar documents
[0569] p 0318 garbage

Chapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Programming Style and Optimisations - An Overview

D Programming Language

Chapter 1 Getting Started

Heap Management. Heap Allocation

Structure of Programming Languages Lecture 10

Short Notes of CS201

CSE 307: Principles of Programming Languages

Hacking in C. Pointers. Radboud University, Nijmegen, The Netherlands. Spring 2019

CS201 - Introduction to Programming Glossary By

Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Client Code - the code that uses the classes under discussion. Coupling - code in one module depends on code in another module

Seminar report Java Submitted in partial fulfillment of the requirement for the award of degree Of CSE

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Deallocation Mechanisms. User-controlled Deallocation. Automatic Garbage Collection

EL2310 Scientific Programming


Type Bindings. Static Type Binding

Sample Copy. Not for Distribution.

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result.

Examples of Code Roaches. First Draft List Cem Kaner September 11, 2005

CPS 506 Comparative Programming Languages. Programming Language

Pointers and References

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

Principles of Programming Languages. Lecture Outline

Lecture Notes on Memory Management

Vector and Free Store (Pointers and Memory Allocation)

I101/B100 Problem Solving with Computers

QUIZ. What is wrong with this code that uses default arguments?

CS112 Lecture: Primitive Types, Operators, Strings

9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5

Systems software design. Software build configurations; Debugging, profiling & Quality Assurance tools

Lecture Notes on Memory Management

Business and Scientific Applications of the Java Programming Language

QUIZ on Ch.5. Why is it sometimes not a good idea to place the private part of the interface in a header file?

QUIZ Friends class Y;

10. Functions (Part 2)

Object-Oriented Programming

Security Coding Module - Buffer Overflow Data Gone Wild CS1

What are the characteristics of Object Oriented programming language?

CSC 533: Organization of Programming Languages. Spring 2005


Engine Support System. asyrani.com

Topic 9: Type Checking

Topic 9: Type Checking

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Computer Components. Software{ User Programs. Operating System. Hardware

Arrays array array length fixed array fixed length array fixed size array Array elements and subscripting

NOTE: Answer ANY FOUR of the following 6 sections:

Special Topics: Programming Languages

Object Oriented Programming

Sri Vidya College of Engineering & Technology

Real-Time and Embedded Systems (M) Lecture 19

Advanced Programming & C++ Language

Chapter 17 vector and Free Store. Bjarne Stroustrup

Unit 1: Visual Basic.NET and the.net Framework

Undefined Behaviour in C

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Inheritance: Develop solutions by abstracting real-world object and their interaction into code to develop software solutions. Layering: Organization

High Performance Computing MPI and C-Language Seminars 2009

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

CSCI-GA Scripting Languages

Object-Oriented Programming for Scientific Computing

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

Introduction to Programming Using Java (98-388)

How to Break Software by James Whittaker

A brief introduction to C programming for Java programmers

Lectures 5-6: Introduction to C

Lab 03 - x86-64: atoi

The PCAT Programming Language Reference Manual

Pointers and Memory 1

Computer Components. Software{ User Programs. Operating System. Hardware

Programming. Loriano Storchi.

BCS THE CHARTERED INSTITUTE FOR IT. BCS Higher Education Qualifications BCS Level 6 Professional Graduate Diploma in IT EXAMINERS' REPORT

ITP 342 Advanced Mobile App Dev. Memory

CS558 Programming Languages

3. Java - Language Constructs I

COMPILER DESIGN. For COMPUTER SCIENCE

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

New Programming Paradigms

White Paper. How the Meltdown and Spectre bugs work and what you can do to prevent a performance plummet. Contents

Higher Computing Science Software Design and Development - Programming Summary Notes

Review sheet for Final Exam (List of objectives for this course)

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

GO MOCK TEST GO MOCK TEST I

Chapter 17 vector and Free Store

Students received individual feedback throughout year on assignments.

National 5 Computing Science Software Design & Development

CS558 Programming Languages

CSc 520. Principles of Programming Languages 25: Types Introduction

Using Static Code Analysis to Find Bugs Before They Become Failures

Lectures 5-6: Introduction to C

Full file at

102. Introduction to Java Programming

Storage. Outline. Variables and updating. Copy vs. Ref semantics Lifetime. Dangling References Garbage collection

Memory Allocation. Static Allocation. Dynamic Allocation. Dynamic Storage Allocation. CS 414: Operating Systems Spring 2008

Compaq Interview Questions And Answers

Transcription:

Risk Management I.T. Mock Interview Correction General I.T. Questions 1) A computer can only run binary code, whose human-readable version is assembly language. Any higher-level language is only an abstraction developed in order to ease software development, and must eventually be transformed to binary instructions. There are mainly two approaches to do so: compiled languages (e.g. C and C++): the high-level language need to be integrally converted to binary code once the application source code is ready, so as to make it runnable. The developer generally takes care about this one-step process once she wants to publish the application. Compiled softwares are generally fast as they are directly runnable without any need of further conversion procedure; also, the compiler may analyse the whole source code and optimize it. However, compiled languages are less flexible in terms of development as the developer needs to recompile the application each and every time she makes any modification in the source code; debugging is also generally less explicit than with interpreted languages. Still, the developer knows at the time of the compilation if she made (static) errors such as syntax errors, or typing errors (if the language is statically typed). Notably, compiled languages are architecturespecific and need to be recompiled for every environment they target. interpreted languages (e.g. VB, VBA, MatLab, Javascript): the source code is shipped as is, and a tool called interpreter takes care about dynamically converting the source code to binary as the application runs. This live translation service consumes computing power, however, which makes interpreted languages slower than compiled language most of the time; also, it is harder for the interpreter to optimize the code as it does not consider the code integrally in general. Still, its dynamic nature helps the developer which can easily modify and relaunch the application without the painful process of compilation; she may also directly run commands in a shell-like environment (think of MatLab), as the commands may be converted to binary code immediately. Debugging tools are generally of a higher level and provide more information to the developer about the state of the application and the execution flow. Finally, a software may be launched on any environment providing an interpreter without any further complications, but this also implies that the application cannot run if the interpreter has not been previously installed. just-in-time compiled languages (e.g. C#, VB.NET, Java): the high-level language is first compiled to an intermediary - but low level - language at the end of the development phase, e.g. so called byte code for Java or MSIL for C# and VB.NET. The intermediary language keeps general enough to not be architecture specific, however. Once the application is run on the client computer, a just-in-time compiler takes care of the final step, which is generally performed only once (when the application is first run): compiling the intermediary language to binary code. The just-in-time compiler may even benefit from its knowledge of the computer architecture to further optimize the compiled code. As for the interpreted languages, the application may be run on any environment providing a just-in-time compiler (and the required libraries) without the need to recompile, but it also means that the just-in-time compiler and the other required libraries must have been previously installed. 2) Debugging is the process of the process of finding bugs, or errors, in the application. Some errors are qualified of static as they may be found during the programming phase (e.g. syntax

errors) but others, called dynamic errors, might only reveal themselves as the application is run (e.g. a division by zero). Static errors are generally captured during the compilation phase, and are generally easy to spot and correct even with interpreted languages during the execution. Dynamic errors depend on the state of the application during its execution (i.e. the content of each and every variable related to your application) and it is much harder to identify the cause of a crash in this context, as it may be the consequence of a series of complex operations (even pseudo nondeterminist in the case of naive multithreading). Languages development environment generally provide tools to debug the application while it is running. They allow to set breakpoints, where the application should pause, so that the developer can inspect the state of the application and assert its correctness. More advanced tools allow the developer to run the application line by line to follow the execution process precisely and identify the cause of a misconduct (note that in case of parallelism, this is not as straightforward). High-level language provide programming paradigms to capture as soon as possible the potential causes of dynamic errors, such as exception handling mechanisms, but this does not prevent errors made by the developer. Unit testing is the fact of developing a side application whose only goal is to check as many aspects of the behavior of the main application. The unit testing application is run every time the main application is modified, so that it immediately notifies the developer of a feature which ceased to worked because of a modification. Indeed, it is important to realize that industrial applications might have millions of lines of code, which makes them impossible to be understood by a single programmer. The development process is splitted between many teams, which try to work in common but might still corrupt the work of each other as there are a lot of cross dependencies. In any case, even on a single-developer project, the programmer quickly loses the absolute control of her project as the state-space and the external dependencies grow very fast: it is primordial to develop a tool which can systematically test as many features of the application and alert the developer as soon as one of them is corrupt. 3) The type of a variable defines the kind of content it may store, e.g. integers, characters, floating numbers, strings. A strong typing system forces the programmer to explicitly state the type of the variables she uses, and forbids any illegal operation between incompatible types (e.g. trying to store a floating number in a character-typed variable, or trying to add a number and a string); this prevents many errors which may result in an undetermined state of the application. Indeed, if such an operation occurs, it is generally a mistake made by the programmer, or at least it could lead to ambiguities: it is therefore generally a better idea to notify the programmer. Weak typing is much more flexible and tries to guess what would be the best solution to operations involving incompatible types. For instance, adding the number 3 and the character 4 might be automatically transformed by the compiler (or interpreter) by adding the number 3 and the number 4 ; but it is ambiguous as one may also argue that is no more logical than adding the number 3 and the ASCII code of 4, which is 52 : the results of these two operations are completely different. In this particular case, it would be enough to simply read the language manual and find out what is the standard procedure in case of an operation between an integer and a character, but it might become much less clear is other cases. Worse, if you happen to forget this subtlety, and wrongly think that a character is converted to a number using its ASCII code, you will assume that the variable contains 3+ASCII( 4 ) even though it contains 3+4: the application won t crash, but you will certainly have a bug occurrence much later in the execution of the software and it will be very hard to come back to the genesis of the error. In other words, weak typing is quite comfortable for (lazy) programmers but it is much safer to use strong typing. Visual Basic is an example of weak typing language; C++, Java, C# are strong typing languages.

Statically typed languages perform the type check at the time of the compilation once and for all, whereas dynamically typed languages check the correctness of the operation types at runtime only. Statically typed languages have the advantage that any typing error is found early; also, the development tools may analyse the typing structure of the source code and provide help or advices to the programmer (e.g. IntelliSense of VisualStudio). Dynamically typed languages are less strict for the programmer in the sense that he does not need to bother specifying each and every type, but it does not prevent an error occurring during the execution. 4) Passing a parameter by value to a function may somehow be understood as passing a copy of the variable to the function. In other words, if the inner code of the function modifies the parameter, it will not have any impact on the outer variable. Passing a parameter by reference means that it is the outer variable that will be accessed from inside the function: any modification on a parameter passed by reference will impact the outer variable. For instance, consider the pseudocode a function which swaps the content of its parameters: function swap(byval A, byval B) var C = A; A = B; B = C; end function X = 1; Y = 2; swap(x, Y); The final call swap(x,y) does not work as expected as the inner code of the swap function only deals with local copies A and B or the variables X and Y, and the instructions A=B and B=C have no effect on X and Y. X and Y still have the values 1 and 2 after the swap call, respectively. However, a function such as: function swap(byref A, byref B) var C = A; A = B; B = C; end function X=1; Y=2; swap(x,y); will do a proper job as now A and B actually refer to the outer variables passed as parameters. The value of X and Y is 2 and 1 after the swap call, respectively. 5) Memory management mainly involves the dynamic allocation and cleanup of memory. High level languages generally hide the rather complex mechanisms of explicit memory management by providing abstractions and tools which care about these concepts automatically without requiring any attention of the developer. For instance, the developer might deal with an array of data (creating, deleting or resizing it) without asking explicitly the system to allocate some number of octets and without taking care of its removal once she is done with it. A garbage collector is a tool whose unique goal is to identify allocated variables which are no longer in

use, and free the memory associated to them automatically. MatLab, VisualBasic, Java and C# do provide some advanced memory management facilities (not to the same extent however), whereas C and C++ do not, for instance. Explicit memory management is a terrible source of bugs (think of segment fault-type errors, buffer overflows, or memory leaks) and are also sources of vulnerabilities to malicious softwares (e.g. buffer overflow attacks). However, when the performance of a software is crucial, automatic memory management might be weaker as the developer loses control over the execution flow of a part of the program (e.g. she has no control over the execution of the garbage collector). 6) A memory pointer is a variable whose content is the address in memory of another variable. There are generally no pointers in automatic memory management languages as the main goal of pointers is to deal with allocation of memory (note that C# still allows to use pointers in a restricted context). The main uses of pointers are the following: storing the address of a block of memory, which has for instance been allocated by the developer passing parameters by reference (or more explicitly, passing by pointer) to a function so that the inner code may modify the content of the outer variables, or to avoid the copy of heavy variables returning the address of an object dynamically allocated in the inner code of a function dealing with the array arithmetics (e.g. accessing elements) 7) Procedural programming is a paradigm in which the source code mainly consists of procedure (i.e. function) calls, and is otherwise of a very linear nature. Object oriented programming is a paradigm in which tasks are structured in data types (called classes) and are associated to behaviors (methods, or class functions) and properties (members, or class variables). The classes may be instantiated to create objects, which are unique entities based on the class model, are self-contained and have their own state. OOP generally provides more advanced tools such as inheritance, polymorphism and encapsulation, which help design a secure, robust, elegant, modulable and extensible code. C++, C#, Java and Scala do support OOP whereas C for instance, does not. MatLab supports OOP since a recent version, but it only has basic OOP features, so it is clearly not fully OOP. 8) Linked lists, dynamic arrays, hashtables and binary trees are data structure which help store collections of data efficiently. Depending on the use the developer needs (e.g. a fast access to random elements, a fast resize of the structure, a fast insertion of element at an arbitrary position, etc.), some of these structures are more efficient than others. Each of these structures has its strengths and its weaknesses relative to different operations, therefore the developer has to decide carefully which one suits the best her use case. For instance, matrices in MatLab require a fast access to an arbitrary element, but are rarely resized once they have been created; for this reason, the underlying data structure will try to have the lowest order of complexity for accessing arbitrary elements, at the cost of having a higher complexity for resizing operations. linked lists: each element of the collection stores the value of interest plus a pointer to the next element (and potentially a second pointer to the previous element). The developer always keeps track of the address of the first element. This data structure is ideal in order to insert a new data in the collection as is suffices to only alter the pointer of the previous element (if the pointer to such element is known), which is of O(1). However, it is slow for random access (of O(N)), as it does not know where is stored the Nth element in memory unless it first goes successively through the pointer of the 1st element to the 2nd, and then from the 2nd to the 3rd, etc. until the Nth.

dynamic arrays: a block of memory of size N is allocated initially, and the elements can be accessed in O(1) using arithmetics as the variables are stored successively in memory. However, inserting an element in the collection (say, at a position i) can be very costly: if the allocated memory is sufficient to insert a new item, a first step requires to shift all the items from position i one block on the right, and only then write the new element at the position i. If the memory allocated initially is not sufficient to add a new item, a new full block of size N+k (e.g. k=1) must be allocated, and the old data structure must be fully copied in the new memory block, inserting the new element at the right place; finally, the old block of size N must be freed. MatLab matrices are implemented using this kind of structure (even though they are certainly more complex). 9) A design pattern is the solution to a recurrent problem in the context of software engineering. As for algorithms, it is not specific to a particular language, but is rather a generalist best practice guide; still, it often requires OOP features and might therefore be useless for procedural languages. The singleton design pattern gives the solution to the problem of authorizing one instance of a particular class only and takes the following form (in C#): class Foo { private static Foo uniqueinstance = null; private Foo() { } public static Foo Get() { if( uniqueinstance == null ) uniqueinstance = new Foo(); return uniqueinstance; } } Foo f1 = Foo.Get(); Foo f2 = Foo.Get(); // f2 is the same object than f1 (not just a copy) Foo f = new Foo(); // Illegal, does not compile MatLab Questions 1) MatLab is interpreted, dynamically typed and mostly strongly typed. It provides some poor OOP as well as some very basic FP features. It does provide automatic memory management facilities. By default, it passes the parameters by value. 2) A vector (or matrix) contains a unique data type, and is optimized for linear algebra operations. A cell array is more flexible in the sense that it may mix any (complex) types for each of its elements without restriction, but it is less suited for numerical calculus. Vectors and matrices are implemented in a dynamic array-like data structure type for the reasons given above. 3) Method overloading allows to declare several methods with the same name but differing in their number of parameters (or their parameter types), therefore having a potentially different body. MatLab provides a cheap version of overloading: the programmer may use the variable nargin in the function to know how many parameters have been set when the function

was called. This way, the inner code of the function might react differently if some parameters are missing. In order to capture the 3rd return parameter of the function but not the 2 first parameters, the syntax is: [~,~,third] = somefunction(someparam); 4) See int2str, str2int, datestr, datenum. 5) See sub2ind, ind2sub.