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
-
A memory location.
-
A memory store that you cannot change.
-
A value.
-
A memory store that you can change.
D
Correct answer
Explanation
A variable is a named memory location used to store data that can be modified or updated during the program's execution. This distinguishes it from a constant.
-
To explain the code
-
To ask the coder how he/she is doing
-
To make the code work
-
To avoid a syntax error
A
Correct answer
Explanation
Comments are non-executable lines in code used by programmers to document and explain what the code does for human readers. They do not affect program execution.
-
Not consistent or having a fixed pattern; liable to change
-
Somewhere to store functions
-
Names used to store one or morevalues e.g. a users ages
-
A symbol that represents a quantity
C
Correct answer
Explanation
Variables are named containers for storing values that can be changed. Option C correctly describes variables as named storage for values like age.
B
Correct answer
Explanation
A logic error occurs when the code runs without crashing but produces incorrect results because the underlying algorithm or logic is flawed.
A
Correct answer
Explanation
A syntax error occurs when the code violates the rules of the programming language, such as missing parentheses or incorrect keywords, preventing the program from running.
-
Loops
-
Selection
-
Iteration
-
Procudure
B
Correct answer
Explanation
Selection statements (also known as conditional statements) allow a program to choose different paths of execution based on whether a condition is true or false.
B
Correct answer
Explanation
The 'while' statement is a control structure used for iteration, meaning it repeats a block of code as long as a specified condition remains true.
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.
-
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.