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. #protected

  3. !package

  4. -private

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

In UML class diagrams, visibility symbols are: + (public), - (private), # (protected), and ~ (package/default). Option B claims # represents protected, but # actually IS the correct UML symbol for protected. The question asks for the WRONG pair, and + for public, ! for package, and - for private are all correct. Only # for protected is correctly represented, making B the wrong statement if it claimed otherwise.

Multiple choice technology operating systems
  1. typset x=32+8

  2. set x=32+8

  3. let x=32+8

  4. x=32+8

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

In shell scripting, 'let' is used for arithmetic operations. The command 'let x=32+8' evaluates the arithmetic expression 32+8 and assigns the result 40 to variable x. Option A uses 'typset' which is a typo for 'typeset' (used for variable declaration), Option B 'set' is for shell options/parameters, and Option D is just a string assignment in most shells.

Multiple choice technology programming languages
  1. True

  2. False

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

Static variables belong to the class itself rather than to any instance. They are not serialized because serialization is meant to save the state of individual objects, and static variables represent shared class-level state. Serializing them would duplicate shared state across deserialized instances, breaking the design.

Multiple choice technology web technology
  1. isNumber()

  2. isString()

  3. typeof()

  4. Option 1 & 2

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

The typeof operator in JavaScript returns a string indicating the type of the operand's value. It can return 'number', 'string', 'boolean', 'undefined', 'object', or 'function'. Functions like isNumber() and isString() are not built-in JavaScript functions.

Multiple choice technology web technology
  1. Mode value is 1Mode value is 2Mode value is 3

  2. Mode value is 1

  3. JavaScript error in the browser

  4. None of the above

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

This switch statement lacks break statements, so it exhibits fall-through behavior. Once mode matches case 1, execution continues through case 2 and case 3, printing all three messages. Without break statements, every case after the matching one executes.

Multiple choice technology programming languages
  1. No Value Returned

  2. -1

  3. 1

  4. 0

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

C++ programs conventionally return 0 to the operating system to indicate successful execution, following a universal programming standard. Non-zero return values typically signal errors or specific exit conditions. This convention allows scripts and other programs to programmatically detect whether a program completed successfully.

Multiple choice technology programming languages
  1. Inline functions

  2. virtual functions

  3. Both A and B

  4. None of the above

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

Inline functions eliminate function call overhead by inserting the function's code directly at each call point during compilation, rather than using a standard function call mechanism. This optimization is particularly useful for small, frequently-called functions. Virtual functions enable polymorphism through dynamic dispatch and are not inlined by default.

Multiple choice technology programming languages
  1. conditional statement

  2. assignment statement

  3. looping statement

  4. None of the Above

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

Assignment statements using the = operator assign values to variables in C++. Conditional statements (if/else) control flow, and looping statements (for/while) repeat code blocks - none directly assign values.

Multiple choice technology programming languages
  1. Data Hiding

  2. Encapsulation

  3. Operator Overloading

  4. None Of the Above

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

The standard C++ input/output streams cin and cout utilize operator overloading. Specifically, the bitwise left shift << and right shift >> operators are overloaded as insertion and extraction operators to perform stream I/O operations.

Multiple choice technology programming languages
  1. two, two, one

  2. two, three, one

  3. two, two, three

  4. two, two, two

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

In SAS macros, &one resolves to 'two' (first PUT). &&one triggers double resolution - it resolves &one to 'two', then resolves &two to 'three' (second PUT). &&&one is triple resolution - &one to 'two', &two to 'three', &three to 'one' (third PUT). The output is: two, two, three. Option C is correct.

Multiple choice technology programming languages
  1. holds the input record for the next INPUT statement to read in the same iteration of the DATA step

  2. holds the input record for the next INPUT statement to read across further iterations of the DATA step

  3. holds the input record for the current input statement to read across further iterations of the DATA step

  4. All of the above

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

The single trailing at-sign (@) is a line hold specifier that keeps the input buffer in the current iteration, allowing the next INPUT statement in the same DATA step iteration to continue reading from the same record. It does NOT hold across iterations (that would be double trailing @@). Option A correctly describes this behavior.