What is the difference between compiler and profiler?
A profiler examines source code or machine code to determine memory and performance complexities, usage of certain instructions and the frequency and duration of function calls. Profilers are used as an aid to optimising code during the performance engineering phase of development.
A compiler processes source code to produce machine code. A compiler also optimises the emitted code through inline expansion, compile-time computations, tail-call recursions, code re-ordering and so on. Compiler optimisations are well-defined, but the analysis is primitive compared to profiling which performs more extensive and time-consuming analysis of the code.
What makes a parameter a constant reference?
In C++, the const modifier makes a reference a constant reference.
int i = 42;
const int& r = i;
In the above example, both r and i refer to the same object: a primitive integral with the value 42. That is, r is an alias for i; they are one and the same object. However, the reference r is declared constant so we cannot change the object it refers to by assigning a new value to it. But we can assign a new value to i. And since r and i are the same object, the value of r also changes, despite being decalred constant.
Normally you would not use a constant reference to refer to a local object, since the constness of the reference cannot be guaranteed. However, when we pass an object to a function that expects a constant reference to an object, we give a gurantee to the caller that the object's immutable members will not be changed by the function. This is because the function only has access to the object through the constant reference (formal argument), not the reference we actually passed (actual argument). Therefore it only has access to the constant member functions.
Note that mutable members are nonstatic members that are declared mutable. Typically these will be declared private, for internal use only, such as counters or iterators. As such, modifying a mutable member does not alter an object's external state, as defined by its immutable members. This allows us to invoke constant member functions, which assures us that the object's external state remains unchanged, regardless of the internal state.
Mutable members can also be used to enable lazy construction. That is, an accessor initialises a complex embedded member object when it is first accessed, rather than during construction. This allows the containing object to be constructed much faster, provided the accessor is not invoked as part of the construction process of course. In order for this to work, the embedded member must be a mutable pointer that is initially NULL. When the accessor is invoked for the first time, the complex member is constructed and assigned to the NULL pointer which is then returned (usually by constant reference, but not always). Thereafter, the pointer is no longer NULL and can simply be returned on subsequent accesses. The main advantage of lazy construction is that if the accessor is never called before the containing object falls from scope, we don't waste time and memory constructing an embedded object that was never actually required (and if we had a thousand containing objects, we'd be constructing a thousand embedded objects for no good reason). However, all accessors must be declared constant as they must be accessible to all other member functions, including constant member functions. If the member were not mutable, lazy construction of that member becomes impossible.
What are environment variables?
Environment variables are a set of dynamic values that can
affect the way running processes will behave on a computer.
When possible you should advoid using what variables in a program?
Global Variables
Or: variables with names longer than 128 characters.
What are the characteristics of procedure-oriented programming?
Previous answer is incorrect. Procedural programming languages derive from structured programming and primarily introduce the concept of the procedure call (function call). All imperative object-oriented languages are procedural languages and therefore structured languages, thus they address all the issues mentioned in the previous answer.
We use declarative (non-procedural) programming languages when we know what is to be solved and use imperative programming languages when we know how to solve it. Some languages such as Lisp and SQL are both declarative and imperative.
There are no advantages/disadvantages as such since they are used for entirely different purposes.
For example, HTML is imperative and we use to specify what is to be rendered while JavaScript is declarative and we use it to specify how it is to be rendered and/or provide user-interaction.
What is the lifetime of local variables in a function?
If the variable is local to the function it exists until the function returns.
What is the parameter specification for the public static void main method?
The Main method is the method in which execution to any java program begins.
A main method declaration looks as follows:
public static void main(String args[]){
}
The method is public because it be accessible to the JVM to begin execution of the program.
It is Static because it be available for execution without an object instance. you may know that you need an object instance to invoke any method. So you cannot begin execution of a class without its object if the main method was not static.
It returns only a void because, once the main method execution is over, the program terminates. So there can be no data that can be returned by the Main method
The last parameter is String args[]. This is used to signify that the user may opt to enter parameters to the java program at command line. We can use both String[] args or String args[]. The Java compiler would accept both forms.
What does a tilde symbol usually mean at the beginning of a web address?
The tilde symbol in a web address (eg. http://www.website.com/~tim) usually means that the website belongs to the user with the name after the tilde (in this example, the username is "tim")
What does buffer overflow mean?
A buffer overflow occurs when a program tries to store some amount of data in a location which cannot contain that amount of data. For example, trying to store an array of 10 integers in an array with room for 5 integers will cause a buffer overflow.
Buffer overflows are common in C/C++, specifically in the strcpy function. This function copies the data from one string (char array) into another. It is often abused by clever hackers to either crash a program or to inject their own instructions onto the execution stack.
The "extra" data copied over from the larger array doesn't magically disappear. The "overflow" refers to that data overwriting data on the stack. While this will often just crash the program (or computer), those clever hackers mentioned above may happen to know enough about the program structure to be able to insert their own low-level computer instructions to execute arbitrary code on the machine.
Why is top-down testing not an effective strategy for testing object oriented system?
Each object should be responsible for its own logic and data, and so each object's tests should be responsible for its own tests. The top-down approach is the polar opposite of this design, as the top level object would be responsible for testing all of its enclosed objects. This works well in procedural programming, but explicitly violates the concepts of object oriented programming, which states that no object should be concerned about the details of any other object's internal design.
How do you set the null value in array?
Depends on the programming language, some languages may have already initialize an array with null (or the default value of the type), some of them require explicitly assignments by stepping through each element of that array, and assigning them with null. (imperative languages)
What is degeneracy in linear programing problem?
the phenomenon of obtaining a degenerate basic feasible solution in a linear programming problem known as degeneracy.
There is no best, worst or average case running time for bucket sort. We must assume that the number of elements in the list is comparable to the possible number of values in the list. Making it O(n).
Correct me if I am wrong but if the values in the list are already sorted or close to being already sorted it would be O(n lg n).
How are the base 16 and base 2 numbers related?
Both base 16 and base 2 number systems use binary numbers (1 and 0) to write out and define decimal numbers.
What are examples of support classification systems?
Support classification information systems are transaction processing systems, management information systems, knowledge management systems, office automation systems, decision support systems, group support systems.
What dialog box allows you to sort by cell attribute?
The Sort dialog box available from the Data menu item,
What is the difference between program and programming?
define program
i. program means set of instruction which are required for a particular type of task is called program
ii. set of instruction or commands which are given for the computer to do different activity or jobs or works is called program
define programming
the process of creating/modifying a program; some people's job, others' hobby
It means Terminate-Stay-Resident. A TSR is a program that remains in memory when the program ends.