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

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.

Multiple choice technology programming languages
  1. True

  2. False

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

In C and C++, sizeof is an operator (compile-time), not a keyword in the same category as if, while, etc. It's a built-in operator that evaluates to the size of a data type. The question's phrasing makes a technical distinction between keywords and operators.

Multiple choice technology databases
  1. First string

  2. Second string

  3. Start position

  4. End position

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

The STUFF function in SQL Server uses four parameters: the source string (first string), start position (where deletion begins), length (number of characters to delete), and the replacement string (second string). There is no 'end position' parameter - the function uses length instead to determine how many characters to remove before inserting the replacement string.

Multiple choice technology databases
  1. Their name must begin with @

  2. They are local to the batch or stored procedure where they are declared

  3. They can be declared in a select statement

  4. They cannot have a datatype of text or image

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

Local variables in Sybase must begin with the @ symbol (option A is true). They are local to the batch or stored procedure where declared (option B is true). They cannot have text or image datatypes (option D is true). Option C is NOT true - variables cannot be declared in a SELECT statement. They must be declared using the DECLARE statement before being used in SELECT or other statements.