Computer Knowledge
Programming Fundamentals
2,611 Questions
Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.
Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references
Programming Fundamentals Questions
-
Variable name should start with alphabet.
-
Variable name contains the space.
-
Variable name should be different from the keywords.
-
Variable name contains underscore(_).
B
Correct answer
Explanation
Space is not allowed in variable name. For example, RollNum is valid and Roll Num is invalid variable name.
-
value and types of variable
-
name and location in the memory
-
its value can change during execution.
-
all of these
D
Correct answer
Explanation
All of these are the characteristics of Variable. Variables must have its name, data type and value. Without data type variables cannot be declared. Variables also have some location in memory. And variables' value can be changed during the execution of a program.
-
Structure
-
Function
-
Array
-
All of the above
D
Correct answer
Explanation
All structure, function and arrays are the derived data types. Derived data types are derived from base data type.
-
Only A
-
Only B
-
Both A and B
-
Neither A nor B
A
Correct answer
Explanation
Byte code is always generated by the Java compiler. This byte code is platform independent.
-
switch(exp)
{
case value1: statement_1;
case value2: statement_2;
……………………
case valuen: statement_n;
[default: statements ;]
}
-
switch(exp)
{
case value1: statement_1;
case value2: statement_2;
……………………
case valuen: statement_n;
default: statements ;
}
-
switch(exp)
{
case value1: statement_1;
case value2: statement_2;
……………………
case valuen: statement_n;
}
-
switch(exp)
{
case value1; statement_1;
case value2; statement_2;
……………………
case valuen; statement_n;
[default: statements ;]
}
A
Correct answer
Explanation
The correct syntax is as follows:
switch(exp)
{
case value1: statement_1;
case value2: statement_2;
……………………
case valuen: statement_n;
[default: statements ;]
}
The default statement is optional.
-
Switch
-
Integer
-
Default
-
Boolean
-
All of the above
-
$S_1 and\ S_2$
-
$S_1 and\ S_3$
-
$S_2 and\ S_3$
-
$S_1,S_2\ and\ S_3$
-
<font size="2">I</font>t allocates space for the literals.
-
<font size="2">I</font>t compute<font size="2">s</font> the total length of the program.
-
<font size="2">I</font>t builds the symbol table for the symbols and their value.
-
<font size="2">A</font>ll of these
D
Correct answer
Explanation
The first pass of a two-pass assembler performs three key tasks: allocating space for literals/pool table, computing the total program length (for address calculation), and building the symbol table with symbol addresses. All options are correct.
-
Global common subexpression
-
Copy propagation
-
Register allocation
-
Code motion
C
Correct answer
Explanation
a, b and d are ways of code optimization, register allocation happens in code generation stage, so the option c is the odd one.
-
No left recursive or ambiguous grammar can be LL(1)
-
The class of grammars that can be parsed using LR methods is a proper subset of the class of grammars that can be the passed by LL method
-
LR parsing is non - back tracking method
-
LR methods can describe more languages than LL - grammars
B
Correct answer
Explanation
Grammar passed by LR methods is a proper superset of the class of grammar parsed with LL method
-
copy propagation
-
code motion
-
dead code elimination
-
insufficient information
D
Correct answer
Explanation
This is an example of loop - invariant code motion. But here no information is provided about the change of loop variable.
-
i is true but ii is false.
-
i and ii are true and ii is the cause of i.
-
i and ii are true but ii is not the cause of i.
-
Both of them are false.
C
Correct answer
Explanation
Indirect triple consist of a listing of pointers to triples, rather than a listing of triples themselves.
-
Syntactical errors
-
Symentical errors
-
Lexical errors
-
Pass 1 error of the compiler
-
Program load time error
B
Correct answer
Explanation
These errors are runtime errors due to wrong calculations or wrongly understood expressions. Such errors are identified as exceptions during runtime.
-
exp(x)
-
pow(x,y)
-
sqrt(x)
-
None of these
B
Correct answer
Explanation
This function raise x to the power of y in a C language.
-
int
-
char
-
float
-
none of these
A
Correct answer
Explanation
All 'C' program returns integer type of value by default, if the return type is not specified.