answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

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 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.

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.

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.

What is the worst case running time for Bucket sort algorithmWhat kinds of change you expect to makes it On lgn?

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 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

What is meant by TSR in C?

It means Terminate-Stay-Resident. A TSR is a program that remains in memory when the program ends.

What is a node id?

It is the value of the attribute id of a node. It is used when manipulating the DOM and can be accessed by using the function getElementById() of the document object in JavaScript

Why a In the linked list structure Overflow can never occur unless the memory is actually full?

That's not quite true...

It is true that overflow in a linked list structure can not occur so long as there is at least one chunk of allocatable memory large enough to hold one element.

It is not true, however, that overflow can nover occur unless memory is actually full. This is because you can still have allocatable memory, while not having any contiguous chunks large enough to satisfy a single request.

What is the program to figure out how many numbers from 0 to 9 are needed for 1 to 89 for example?

#include<iostream>

#include<array>

#include<sstream>

std::array<int,10> get_frequency (int range_min, int range_max) {

if (range_max<range_min)

std::swap (range_min, range_max);

std::array<int,10> digit {};

for (int count {range_min}; count<=range_max; ++count) {

std::stringstream ss {};

ss << count;

std::string s {};

ss >> s;

for (auto c : s) {

++digit[c-'0'];

}

}

return digit;

}

int main () {

std::array<int,10> digit {};

digit = get_frequency(1, 89);

std::cout << "In the range 1 to 89...\n";

for (int d {0}; d<10; ++d) {

std::cout << "\tthe digit " << d << " appears " << digit[d] << " times.\n";

}

}

Output:

In the range 1 to 89...

the digit 0 appears 8 times.

the digit 1 appears 19 times.

the digit 2 appears 19 times.

the digit 3 appears 19 times.

the digit 4 appears 19 times.

the digit 5 appears 19 times.

the digit 6 appears 19 times.

the digit 7 appears 19 times.

the digit 8 appears 19 times.

the digit 9 appears 9 times.

How many digits in bar code?

That is almost like asking how many digits are in a number. The only limit is the amount of space available for a barcode. Even the size of most scanners does not create an absolute limit because there are barcode readers that look like a pen and read the barcode information serially (one digit at a time).

Perhaps you would like to rephrase your question to find out about a particular barcode application. For example, Universal Product Codes (UPC's) usually have ten digits. The first five identify the manufacturer or distributor, and the other five identify a unique product, including a particular size or quantity of the product. UPC's do not contain any price information; that information is cross referenced by the store's computer after the UPC is scanned.

How you declare class scoped variables and member functions?

To scope class members to the class (rather than to instances of the class), declare them as static members of the class. Static members are accessible even when no instances of the class exist. As such, static member functions do not have access to a 'this' pointer, unlike ordinary (nonstatic) member functions.