Programming Basics Flashcards

1
Q

Two types of scoping

A

Static and Dynamic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When a function is called, what operation occurs in stack?

A

PUSH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When a function is over, what operation occurs in stack?

A

POP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Within the same function, are multiple variable of the same name allowed?

A

NO

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Where are local variables stored?

A

Stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Where are global variables stored?

A

Static area

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

3 parts of main memory

A

Stack, Heap, Static area

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

To store in heap area , which keyword is used?

A

malloc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which part of main memory is least in size?

A

Static area

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Default value in static area?

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Default value in stack area?

A

garbage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Global variable are allocated memory at which time?

A

Compile time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Static memory allocation allocates memory at?

A

Compile time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Static memory allocation is also known as?

A

Early Binding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In dynamic memory allocation, memory estimated at?

A

Runtime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Static can be mapped to?

A

Compiler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Dynamic can be mapped to?

A

Processor

18
Q

&

A

Reference operator

19
Q

*

A

Dereference operator

20
Q

Local variable memory estimated at?

A

Runtime

21
Q

Identify error : variable with same name declared twice in the same function

A

Multiple declaration error

22
Q

Identify error: operation b/w two variable of different type

A

Type mismatch error

23
Q

Identify error : variable used without declaration

A

Undeclared variable error

24
Q

Solution of scope problem

A

Static scoping and Dynamic scoping

25
Q

Who handles static scoping?

A

Compiler

26
Q

Who handles dynamic scoping?

A

Processor

27
Q

Static scoping?

A

If no local, take global

28
Q

Dynamic Scoping?

A

Go to the prev functions, if variable not found in any function, use global variable’s value

29
Q

Which scoping is more difficult to implement?

A

Dynamic

30
Q

Default scoping technique?

A

Static

31
Q

When does static scoping give error?

A

If variable not present local and also not global then error

32
Q

When does dynamic scoping give error?

A

If variable is not present in any function and also not global

33
Q

In worst case , dynamic scoping prints what value of variable?

A

Global value

34
Q

Why indexing of array start from 0?

A

So that no time is taken in calculating offset value

35
Q

int a=26;

A

Initialisation

36
Q

int a;

A

Declaration

37
Q

a=26;

A

Modification

38
Q

If any value is passed to a function suppose int D(int a, int b) then what happens?

A

Then function D makes its local copies of a and b and stores the passed value in it.

39
Q

What is the difference b/w initialization, declaration and modification

A

Initialization and declaration creates memory whereas modification does not

40
Q
A