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 technology mainframe
  1. PARA A

  2. PARA B

  3. PARA C

  4. PARA D

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

The COBOL GOTO statement with DEPENDING ON uses 1-based indexing: GOTO A,B,C,D DEPENDING ON X transfers control to the first label when X=1, second label when X=2, third when X=3, fourth when X=4. When X=2, control transfers to PARA B. This is a computed GOTO based on the ordinal position of the labels.

Multiple choice technology business process management
  1. catch,finally

  2. finally

  3. catch

  4. catch,catch,finally

Reveal answer Fill a bubble to check yourself
A,B,D Correct answer
Explanation

In Java, a try block must be followed by either a catch block, a finally block, or both. The options correctly identify valid combinations like try-catch-finally, try-finally, and multiple catches. However, the option "catch" is marked false when a single catch block is also syntactically valid in Java. Since 'catch' is marked false, the stored answers are partially inconsistent, but try-catch-finally and try-finally are indeed correct.

Multiple choice technology business process management
  1. catch,finally

  2. finally

  3. catch

  4. catch,catch,finally

Reveal answer Fill a bubble to check yourself
A,B,D Correct answer
Explanation

In Java, a try block must be followed by either a catch block, a finally block, or both. Option A shows catch+finally which is valid. Option B shows finally only which is also valid. Option D shows multiple catch blocks followed by finally, which is valid syntax for handling different exception types sequentially.

Multiple choice technology web technology
  1. True

  2. False

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

JavaScript allows return statements in finally blocks. When a finally block contains a return statement, it will override any return value from the try or catch blocks. This is generally considered a bad practice as it can suppress exceptions and make debugging difficult, but it is syntactically valid.

Multiple choice technology web technology
  1. True

  2. False

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

The CTS (Common Type System) defines how types are declared and used in the .NET framework. Pointers are NOT part of the CTS - they are part of 'unsafe' code in C# and operate outside the normal type system safety guarantees. Pointers are a non-CLS compliant feature.

Multiple choice technology programming languages
  1. True

  2. False

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

Exceptions can indeed be rethrown in Java and other languages. After catching an exception, code can explicitly rethrow the same exception (or wrap it in a new exception) using 'throw;' or 'throw ex;'. This is commonly used for adding context, logging, or handling exceptions at multiple levels of the call stack.

Multiple choice technology programming languages
  1. True

  2. False

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

A double can be cast to a byte in Java using explicit casting, but this will result in data loss since a byte is only 8 bits while a double is 64 bits. The cast truncates the decimal part and may overflow if the value is outside byte range (-128 to 127).

Multiple choice technology mainframe
  1. ALPHABETIC

  2. ALPHANUMERIC

  3. NUMERIC

  4. BOOLEAN

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

BOOLEAN is not a standard COBOL datatype. Traditional COBOL uses PICTURE clauses to define data formats like ALPHABETIC (A), ALPHANUMERIC (X), and NUMERIC (9 or S9). While modern COBOL implementations may support boolean-like conditions, BOOLEAN as an explicit datatype is not part of standard COBOL. The question asks which datatype is NOT used in COBOL - BOOLEAN is the correct answer.

Multiple choice technology mainframe
  1. True

  2. False

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

WHILE is not a keyword in standard COBOL. COBOL uses PERFORM...UNTIL for looping constructs, not WHILE. For example, 'PERFORM UNTIL condition' or 'PERFORM varying... UNTIL condition'. The WHILE keyword exists in languages like C, Java, and Python, but not in traditional COBOL. False is the correct answer.

Multiple choice technology programming languages
  1. True

  2. False

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

In Java, you cannot directly cast a wrapper Byte object reference to a primitive double or a Double object reference because they belong to different class hierarchies. Although auto-unboxing allows implicit conversion during assignments, an explicit object reference cast is invalid and will fail compilation.

Multiple choice technology
  1. Active

  2. Passive

  3. Can be Active or Passive

  4. None

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

A Mapplet in Informatica can be either Active or Passive depending on its transformations. An Active Mapplet contains at least one Active transformation (like Aggregator, Filter, Joiner) that changes the number of rows passing through it. A Passive Mapplet contains only Passive transformations (like Expression) that maintain the same row count. The classification depends entirely on the transformations used within the mapplet.