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. int

  2. String

  3. Variable

  4. Function

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

A variable is a named storage location in memory that can hold a value, which can be changed or reassigned during program execution.

Multiple choice
  1. char arrays

  2. int arrays

  3. byte arrays

  4. Strings

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

The Java String class has constructors that accept char arrays, byte arrays, and String objects, but it does not have a constructor that accepts an int array.

Multiple choice
  1. The point at which the recursion loop will stop

  2. The element of a program that can be represented recursively

  3. An error causing the recursion loop to stop

  4. A for loop

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

In recursion, the base case is the condition that terminates the recursive calls. Without it, the function would call itself indefinitely, leading to a stack overflow error.

Multiple choice
  1. execute

  2. read

  3. write

  4. nothing

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

In the standard Unix permission triplet (rwx), the 'x' character stands for execute permission.

Multiple choice
  1. True

  2. False

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

Unchecked exceptions, which are subclasses of RuntimeException, do not have to be caught or declared in a throws clause. The compiler does not force you to handle them, although you can choose to do so. Only checked exceptions must be handled using a try/catch block or declared in the method signature.

Multiple choice
  1. True

  2. False

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

A try-finally block is completely legal in Java. You do not need a catch block if you have a finally block, which is useful when you want to ensure cleanup code runs regardless of whether an exception is thrown, while letting the exception propagate up the call stack.

Multiple choice
  1. int 5 = x;

  2. 5 = x int;

  3. int x = 5;

  4. x = 5 int;

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

In Java, variable declaration and assignment must follow the syntax: data type, followed by the variable name, the assignment operator (=), and finally the value. Therefore, 'int x = 5;' is the only syntactically correct option.