Computer Knowledge
Programming Fundamentals
2,381 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
-
Syntax error
-
Symantic error
-
Logical error
-
Internal error
A
Correct answer
Explanation
Compilers check source code against the language's grammar rules and report violations as syntax errors. These include missing semicolons, unmatched brackets, or incorrect keyword usage. Semantic errors relate to meaning (e.g., type mismatches) and may only be caught by some compilers, while logical errors (bugs) and internal errors are runtime or system issues beyond compilation.
-
include[]
-
#include()
-
include()
-
#include{}
-
getdouble()
-
is_date()
-
get_type()
-
is_double()
D
Correct answer
Explanation
In PHP, is_double() (which is an alias of is_float()) is used to check if a variable is of type float/double. While gettype() (not get_type) returns the type string, is_double() specifically finds out if it is that type.
B
Correct answer
Explanation
The goto keyword exists and is functional in both C and Java languages. While discouraged in modern programming due to concerns about code readability and maintainability, it remains a reserved keyword that can be used to transfer control within a function.
A
Correct answer
Explanation
Java removes direct pointer manipulation and pointer arithmetic from C, as memory management is handled by the JVM. Concepts like pointers, dereferencing operators (*, &), and manual memory allocation (malloc, free) don't exist in Java, reducing complexity and common memory-related errors.
-
inside loops
-
inside switch condition
-
with labels
-
with labels in loops only
-
do while
-
while
-
for
-
if else
A
Correct answer
Explanation
The do-while loop is the only looping construct that guarantees execution of its body at least once, because the condition is checked after the first iteration. While and for loops check the condition before entering, so they may execute zero times.
-
Syntax error
-
Symantic error
-
Logical error
-
Internal error
A
Correct answer
Explanation
Compilers check for violations of the language's grammatical rules, known as syntax errors. Semantic and logical errors are often only detectable during runtime or through debugging, as the code may be syntactically valid but logically flawed.
-
[2 3 ; 3 15] / [5 ; 8]
-
[2 3 ; 3 15] \ [5 ; 8]
-
[2 3;3 15] / [5 8]
-
[2 3;3 15] \ [5 8]
B
Correct answer
Explanation
To solve Ax=b in MATLAB, use the backslash operator: A \ b. This represents [2 3; 3 15] \ [5; 8]. Forward slash (/) would solve xA=b, which is wrong here. Options C and D use row vectors [5 8] instead of column vectors [5; 8].
-
sin(Pi/2)
-
sin(90)
-
Sin(pi/2)
-
sin(pi/2)
D
Correct answer
Explanation
MATLAB trigonometric functions use radians, not degrees. sin(90°) requires converting 90° to radians: 90° = pi/2 radians. Option B (sin(90)) is wrong because 90 is treated as 90 radians. Option C has wrong case (Sin vs sin). Option A has wrong case for pi (Pi vs pi).
-
P contains the address of an element in DATA.
-
P points to the address of first element in DATA
-
P can store only memory addresses
-
P contain the DATA and the address of DATA
A
Correct answer
Explanation
In programming, a pointer is a variable whose value is the memory address of another variable. While it can store addresses, the functional definition is that it 'points' to the location of data.
-
underflow
-
saturated
-
overflow
-
housefull
A
Correct answer
Explanation
When START=NULL in a linked list, it means the list is empty. Attempting to remove from an empty list causes underflow - trying to remove something that doesn't exist. Overflow occurs when there's no space to add new elements.
-
Infinite
-
Depends on RAM capacity
-
Depends on compiler
-
none of above
B
Correct answer
Explanation
Theoretically, you can nest loops many times, but each level of nesting and the variables involved consume memory. The practical limit is determined by the system's RAM and stack/heap limits rather than a fixed compiler constant.
-
zero only
-
ZERO or Void Pointer
-
Zero or void
-
none
B
Correct answer
Explanation
In C programming, NULL is a macro that expands to either 0 or a void pointer (void*) depending on context. It represents a null pointer constant. The correct answer captures both possibilities. Option C is similar but 'void' alone is not a pointer type.
A
Correct answer
Explanation
This statement is valid in Java. The 'new Integer(12)' creates an Integer object through autoboxing, and 'int _samId' unboxes it to a primitive int. The double underscore in '_samId' is a valid variable name in Java. This is syntactically correct and will compile.