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
B
Correct answer
Explanation
A single character, such as 'Y', is represented by the character (char) data type.
B
Correct answer
Explanation
The value "true" is enclosed in quotes, which makes it a sequence of characters, classified as a String data type.
B
Correct answer
Explanation
The value false is a logical value representing one of two states, which is the definition of a boolean data type.
B
Correct answer
Explanation
The value 156.2 contains a decimal point, which is represented by the float (floating-point) data type.
B
Correct answer
Explanation
A string is a sequence of characters used to represent text. 'Hello World' is a text sequence, making String the correct data type.
-
int
-
String
-
Variable
-
Function
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.
-
Start
-
Beginner
-
Hello World
-
Hello
C
Correct answer
Explanation
The 'Hello World' program is the traditional first program written by beginners to verify that their development environment is set up correctly.
-
char arrays
-
int arrays
-
byte arrays
-
Strings
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.
-
Only two
-
As many as you want
-
None
-
One
B
Correct answer
Explanation
An if-else structure can have an unlimited number of else-if blocks to handle multiple conditional branches.
B
Correct answer
Explanation
A city name is a sequence of characters, which is represented by the String class in Java.
-
The point at which the recursion loop will stop
-
The element of a program that can be represented recursively
-
An error causing the recursion loop to stop
-
A for loop
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.
-
execute
-
read
-
write
-
nothing
A
Correct answer
Explanation
In the standard Unix permission triplet (rwx), the 'x' character stands for execute permission.
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.
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.
-
int 5 = x;
-
5 = x int;
-
int x = 5;
-
x = 5 int;
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.