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 programming languages
  1. public

  2. static

  3. void

  4. main

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

In Java, 'public', 'static', and 'void' are reserved keywords that have special meaning in the language. 'main' is NOT a reserved keyword - it's simply the name of a method that is commonly used as the entry point for Java applications, but you could technically name a method 'main' in any class.

Multiple choice technology programming languages
  1. void method1 { /* ... */ }

  2. void method2() { /* ... */ }

  3. void method3(void) { /* ... */ }

  4. method4() { /* ... */ }

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

In Java, a valid method declaration requires a return type (or void), a method name, and a parameter list enclosed in parentheses, followed by the method body. void method2() { } correctly satisfies these syntax rules.

Multiple choice technology programming languages
  1. {{}} is a valid statement block

  2. { continue; } is a valid statement block

  3. block: { break block; } is a valid statement block

  4. block: { continue block; } is a valid statement block

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

{{}} is valid - it's a nested empty block. { continue; } is invalid because continue must be inside a loop. block: { break block; } is valid - labeled break can exit any labeled block. block: { continue block; } is invalid because continue requires an enclosing loop, not just a labeled block.

Multiple choice technology web technology
  1. (D) & (E)

  2. b. (A), (D) & (E)

  3. c. (D)

  4. d. (C), (D) & (E)

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

In Java, implements and protected are keywords. NULL (all uppercase) is not a keyword (the literal is lowercase null), extended is not a keyword (the keyword is extends), and string is not a keyword (the class is String). Thus, (A), (D), and (E) are not keywords.

Multiple choice technology programming languages
  1. sizeof

  2. ::

  3. :?

  4. All the Above

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

C++ prohibits overloading the sizeof operator (language built-in for memory size), scope resolution operator :: (fundamental to language syntax), and ternary operator ?: (conditional operator has special syntax rules). These operators are part of the core language and their behavior is fixed by the specification.

Multiple choice technology programming languages
  1. zero

  2. NULL

  3. one

  4. No Entry in vtable

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

Compilers typically set the vtable entry for a pure virtual function to NULL. This ensures that attempting to call a pure virtual function directly (without overriding) results in a predictable error. The NULL entry indicates no implementation is available in this class. Abstract classes cannot be instantiated precisely because they have such NULL vtable entries.

Multiple choice technology databases
  1. NVL

  2. NULLIF

  3. DECODE

  4. COALESCE

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

NVL, NULLIF, and COALESCE are standard SQL functions designed specifically to handle NULL values. While DECODE can handle NULLs in its logic, it is primarily a conditional transformation function rather than a dedicated NULL-handling function like the others.

Multiple choice technology programming languages
  1. Write Once, Run Anywhere

  2. Read Once, Write Anywhere

  3. Read Once, Run Anywhere

  4. Write Twice, Run Once

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

Java's core promise is 'Write Once, Run Anywhere' (WORA), enabled by the Java Virtual Machine (JVM). This means compiled Java code can run on any platform supporting JVM without recompilation. The other options are incorrect.

Multiple choice technology programming languages
  1. Compilation Error - Struct cannot be defined without a name

  2. 193149

  3. Compilation Error - Struct cannot be defined inside a Function

  4. Some Random Number

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

In C, you can define an anonymous structure and instantiate it immediately (struct { ... } var;). This is valid inside a function, and the code will print the assigned integer value 193149.

Multiple choice technology databases
  1. Header

  2. Declarative

  3. Executable

  4. Exception

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

PL/SQL blocks have four sections: Header (optional, for named blocks), Declarative (DECLARE section for variables, types, cursors), Executable (BEGIN...END for main logic), and Exception (EXCEPTION section for error trapping and handling). The Exception section specifically contains functions and handlers for errors.