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
A
Correct answer
Explanation
Serialization in Java is the process of converting an object's state into a byte stream, which can then be persisted into a permanent storage device (like a file or database) or transmitted over a network. Thus, the statement is true.
A
Correct answer
Explanation
The finally block always executes when the try block exits, regardless of how it exits - whether through normal execution, an exception, or a return statement. The only exceptions are if the JVM exits (via System.exit()) or the thread dies. Even when return is the last statement in try, finally runs before the method actually returns.
B
Correct answer
Explanation
Garbage collection only reclaims memory from objects that are no longer referenced. It does not prevent out-of-memory errors - if your program creates objects faster than GC can reclaim them, or holds onto too many live objects, it will still run out of memory. GC manages memory but doesn't guarantee unlimited availability.
-
Integer
-
Null
-
Object
-
String
A
Correct answer
Explanation
JSON has only six basic data types: string, number, boolean, null, object (array), and array. Integer is not a separate type - numbers in JSON are just "number" (which can be integer or floating-point). Null, Object, and String are valid JSON types. Note that Object here refers to JSON objects (key-value pairs), not Java objects.
-
Alert()
-
Eval()
-
Evale()
-
Console()
B
Correct answer
Explanation
JSON is a subset of JavaScript, and in early implementations, eval() was commonly used to parse JSON strings into JavaScript objects. However, this is now considered a security risk and is deprecated in favor of JSON.parse(). The question reflects historical usage patterns. eval() executes arbitrary JavaScript code, making it dangerous with untrusted JSON.
-
For…NEXT
-
While…Wend
-
Loop
-
Do…While
D
Correct answer
Explanation
Do...While loops evaluate the condition after executing the loop body, ensuring the code inside runs at least once before checking whether to continue. For loops, While loops, and basic Loop statements check conditions before execution.
-
You Can’t
-
OptionDeclare
-
Declare Explicit
-
Option Explicit
D
Correct answer
Explanation
In VBScript (used in QTP/UFT), placing Option Explicit at the top of a script forces the developer to declare all variables before using them.
-
The instance gets garbage collected.
-
The code on line 33 throws an exception
-
The code on line 35 throws an exception.
-
The code on line 31 throws an exception
-
The code on line 33 executes successfully.
B,C,E
Correct answer
Explanation
The finally block (line 37) executes whenever control enters the try block. This happens when line 33 throws an exception (caught at line 34), when line 33 executes normally (no exception), or when line 35 throws an exception (still executes finally before exiting). Garbage collection (line 31 exceptions) don't trigger finally.
-
A. final
-
C. native
-
F. abstract
-
G. protected
A
Correct answer
Explanation
In interfaces, fields are implicitly public, static, and final. Valid modifiers include public, static, and final. The question asks which three are valid but only provides A (final) as correct among the options. Native, abstract, and protected are not valid for interface fields. The claimed answer A is correct, but the question asks to choose three and only one is marked correct.
-
A. final
-
C. native
-
F. abstract
-
G. protected
-
Instance Data
-
Target Data
-
Both
-
None of these
C
Correct answer
Explanation
The Informatica Debugger can debug transformations using either instance data (passing test data through) or target data (from actual target tables). This provides flexibility for testing in different scenarios. Options A and B incorrectly suggest only one mode is available.
-
ALLOCATE
-
ALLOC
-
ALLMEM
-
LOADM
-
None of the above
B
Correct answer
Explanation
ALLOC is used to allocate memory at runtime in certain systems (possibly mainframe/COBOL context based on the option names). Standard memory allocation functions are malloc, calloc, realloc (C) or new (C++), but this question appears to test knowledge of a specific system's runtime allocation command. Options A, C, and D are not standard allocation commands.
-
It will run without error
-
Runtime Error
-
Compilation Error
-
None of all
A
Correct answer
Explanation
The Thread class has a constructor Thread(Runnable target), and Thread itself implements Runnable. Passing a Thread object as the Runnable target is valid syntax - it compiles and runs without error. The new Thread object wraps the existing Thread as its Runnable target.
-
- char
-
- byte
-
- short
-
- int
-
- boolean
A,B,C,D
Correct answer
Explanation
Java switch statements accept integral types that can fit in an int: char, byte, short, and int (and their wrapper classes Character, Byte, Short, Integer). Long and float types are not permitted, and boolean is explicitly excluded.