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
-
Runtime Exception
-
finally block will be executed
-
finally block will not be executed
-
Compilation error in else block
C
Correct answer
Explanation
System.exit() terminates the JVM immediately, preventing the finally block from executing. Additionally, the while(true) loop in the if branch never exits, so the finally block would never be reached in that case either. Only if neither branch executes would finally run, but the structure guarantees one of them does.
-
Runtime Exception
-
finally block will be executed
-
finally block will not be executed
-
Compilation error in else block
C
Correct answer
Explanation
This is a duplicate of question 149704. System.exit() terminates the JVM immediately, preventing the finally block from executing. The while(true) loop also never exits. In both cases, the finally block is unreachable.
-
Forward chaining
-
Backward chaining
-
Both of the above
-
None of the above
A
Correct answer
Explanation
Forward chaining automatically recalculates property values whenever any input property changes, using declarative rules. Backward chaining requires explicit triggering when the output value is needed. Forward chaining provides proactive, automatic updates.
-
Clipboard
-
Tracer
-
Performance tool
-
Rules Inspector
B
Correct answer
Explanation
The Tracer tool in Pega is used for debugging and troubleshooting processes. It allows developers to trace execution flow and inspect parameter values, clipboard contents, and other runtime information. Clipboard is for storing data, Performance tool monitors system performance, and Rules Inspector shows rule details.
-
A) Parameter type mismatches.
-
B ) Errors in requirements.
-
C ) Undeclared variables.
-
D ) Uncalled functions.
-
a) The use of a variable before it has been defined
-
b) Unreachable (“dead”) code
-
c) Whether the value stored in a variable is correct
-
d) The re-definition of a variable before it has been used
-
e) Array bound violations
-
1 test for statement coverage, 3 for branch coverage
-
2 tests for statement coverage, 2 for branch coverage
-
2 tests for statement coverage. 3 for branch coverage
-
3 tests for statement coverage, 2 for branch coverage
B
Correct answer
Explanation
Two test cases are sufficient for both statement and branch coverage. The first test (e.g., A=10, B=5, D=5) covers the true branch of the first IF and the true branch of the second IF. The second test (e.g., A=5, B=10, D=10) covers the false branches, achieving full coverage.
-
The use of a variable before it has been defined
-
Unreachable (“dead”) code
-
Whether the value stored in a variable is correct
-
The re-definition of a variable before it has been used
C
Correct answer
Explanation
Static analysis examines code without executing it, so it can find structural issues like undefined variables, unreachable code, or variable redefinitions. However, it cannot verify semantic correctness - whether the value stored in a variable matches the intended business logic. Static analysis tools don't understand your requirements, so they can't tell if 'x = 5' should have been 'x = 10' - only dynamic testing with known inputs and expected outputs can verify correctness.
-
Compiling code is not a form of static analysis.
-
Static analysis need not be performed before imperative code is executed.
-
Static analysis can find faults that are hard to find with
-
Extensive statistic analysis will not be needed if white- Box testing is to be performed.
A
Correct answer
Explanation
When a user-declared constructor is defined, the compiler stops generating the default constructor. This struct has two user-declared constructors: a copy constructor 'A(A& a)' and a converting constructor 'A(double d)'. Because at least one constructor is explicitly declared, the compiler will NOT generate any additional constructors (no default constructor, no copy constructor since one exists, no move constructors). Therefore, the number of implicitly-defined constructors is 0.
B
Correct answer
Explanation
A function call is not always an rvalue in C/C++. Whether it's an rvalue depends on the return type - if a function returns by value, the call is an rvalue, but if it returns a reference, it can be an lvalue. For example, a function returning int& can be used as an lvalue.
B
Correct answer
Explanation
In C++, name lookup is sequential. At the point of x++ in bar(), x has not yet been declared in the namespace. Thus, name lookup fails, and bar() cannot access x without a forward declaration or declaring x first.
-
(a) They are stored on the clipboard as temporary variables
-
(b) They exist only within the context of an activity
-
(c) They can be stored in the database
-
(d) They are stored in a named page that is created automatically
B
Correct answer
Explanation
Local Variables in programming exist only within the context of a specific activity, function, or block. They are created when that context is entered and destroyed when it exits. They are not stored on the clipboard, not automatically stored in databases, and not stored in automatically created pages. Their scope is limited to their defining context.
-
(a) They are stored on the clipboard as temporary variables
-
(b) They exist only within the context of an activity
-
(c) They can be stored in the database
-
(d) They are stored in a named page that is created automatically
B
Correct answer
Explanation
Local variables in PRPC activities are scoped only to the activity's execution context. They are not stored on the clipboard, cannot be persisted to the database, and are not automatically stored in named pages - they exist temporarily during activity execution.
A
Correct answer
Explanation
Functions can have OUT parameters in many programming languages and database systems. In Oracle PL/SQL, functions explicitly support OUT parameters. However, this is context-dependent - SQL Server functions do not allow OUT parameters. The question assumes a context where this is valid.