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

Multiple choice
  1. 0

  2. NULL

  3. Depends on the scale and precision of the datatype.

  4. Without initialization, a variable cannot be used in the executable section of the block.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In PL/SQL, any scalar variable (NUMBER, VARCHAR2, DATE, etc.) that is declared but not initialized automatically gets NULL as its initial value. Option A is incorrect because 0 would need explicit initialization. Option C is wrong because NULL behavior is consistent across scale/precision. Option D is false because uninitialized variables can be used - they'll just be NULL until assigned.

Multiple choice
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

REF cursors in PL/SQL are cursor variables that can be passed between procedures and functions. Unlike static cursors, REF cursors are dynamic and can be opened for different queries at runtime and shared across program units.

Multiple choice
  1. CALL_FORM('Departments);

  2. CALL_FORM('Departments',NO_HIDE);

  3. OPEN_FORM('Departments');

  4. OPEN_FORM('Departments', ACTIVATE, SESSION);

  5. OPEN_FORM('Departments', NO_ACTIVATE, NO_SESSION);

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

OPEN_FORM with the ACTIVATE and SESSION parameters opens the Departments form in a separate session while keeping the Employees form available. This allows clerks to enter and save the new department independently, then return to decide about the employee. CALL_FORM would replace the form entirely, and NO_ACTIVATE/NO_SESSION would not provide the needed independence.

Multiple choice
  1. On-Message only

  2. Post-Commit and On-Message

  3. Post-Database-Commit and On-Message

  4. Post-Insert, Post-Update, Post-Delete, and On-Message

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To replace the default Forms message with specific counts for insert/update/delete operations, you need Post-Insert, Post-Update, and Post-Delete triggers to capture counts after each operation type, plus an On-Message trigger to intercept and replace the FRM-40400 message. Post-Database-Commit fires too late (after transaction completes), and Post-Commit doesn't distinguish between operation types.

Multiple choice
  1. Have the DBA increase the column width in the database.

  2. Change the List Style property for the State item to Combo Box.

  3. Change the List Style property for the State item to T-list.

  4. Change the elements in the list of the State item so that the list elements are the state names and the list element values are the state abbreviations.t.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The error occurs because John is storing full state names in the list elements, but the database column is VARCHAR2(2) expecting only abbreviations. The solution is to use state names as display labels (what users see) while mapping them to 2-character abbreviations as actual values stored in the database.

Multiple choice
  1. Clicking Step Over to step over the execution of the subprogram

  2. Opening the Stack panel, selecting the previous stack frame, and clicking Go

  3. Clicking Step Out to resume stepping through code after the subprogram is called

  4. HE cannot do this in the same debug session. He should click Stop, set a breakpoint immediately after the subprogram code is called, and run the form in debug mode again

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Step Over executes the entire subprogram without stepping through its internal lines, then returns control to the line immediately after the subprogram call. This is exactly what SMITH needs when he realizes the error is in code after the subprogram, not within it.

Multiple choice
  1. The block he is creating is based on a view

  2. The block he is creating is based on a stored procedure

  3. The form contains at least one block in addition to the block he is creating

  4. In addition to the block he is creating, the form contains at least two other blocks that are master detail blocks

  5. The block he is creating is based on a table that has at least one foreign key relationship to another table

Reveal answer Fill a bubble to check yourself
B Correct answer
Multiple choice
  1. TreeMap is the class of Map interface.

  2. HashMap inherits SortedMap interface.

  3. HashMap is not synchronised.

  4. Only (1) and (3) are true.

  5. (1), (2) and (3) all are true.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Yes, both the statements are true.

Multiple choice
  1. 0

  2. 1

  3. 2

  4. 3

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is an example of the islands of isolated objects. By the time line 11 has run, the objects instantiated in lines 6 and 7 are referring to each other, but no live thread can reach either of them.

Multiple choice
  1. 1 and 4

  2. 2 and 5

  3. 3 and 6

  4. 4 and 6

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

(3), (6). Both are legal class declarations. (1) is wrong because a class cannot be abstract and final—there would be no way to use such a class. (2) is wrong because interfaces and classes cannot be marked asstatic. (4) and (5) are wrong because classes and interfaces cannot be marked asprotected.

Multiple choice
  1. You must have a reference to an instance of the enclosing class in order to instantiate it.

  2. It does not have access to nonstatic members of the enclosing class.

  3. It's variables and methods must be static.

  4. It must extend the enclosing class.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Option B is correct because a static nested class is not tied to an instance of the enclosing class, and thus can't access the nonstatic members of the class (just as a static method can't access nonstatic members of a class). Option A is incorrect because static nested classes do not need (and can't use) a reference to an instance of the enclosing class. Option C is incorrect because static nested classes can declare and define nonstatic members. Option D is wrong because it just is. There's no rule that says an inner or nested class has to extend anything.

Multiple choice
  1. Runnable r = new Runnable() { };

  2. Runnable r = new Runnable(public void run() { });

  3. Runnable r = new Runnable { public void run(){}};

  4. System.out.println(new Runnable() {public void run() { }});

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

D is correct. It defines an anonymous inner class instance, which also means it creates an instance of that new anonymous class at the same time. The anonymous class is an implementer of the Runnable interface, so it must override the run() method ofRunnable. A is incorrect because it doesn't override the run() method, so it violates the rules of interface implementation. B and C use incorrect syntax.

Multiple choice
  1. Compilation fails.

  2. odd will always be the output.

  3. even will always be the output.

  4. odd will be the output for odd values of x, and even for even values.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The compiler will complain because of incompatible types (line 4), the if expects a boolean but it gets an integer.