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
-
FIFO
-
LIFO
-
both (a) and (b)
-
None of the above
B
Correct answer
Explanation
A stack follows LIFO (Last In, First Out) - the last element pushed onto the stack is the first one popped off. This is like a stack of plates where you add and remove from the top. FIFO describes a queue, not a stack.
-
For loop
-
While loop
-
if loop
-
All the above
C
Correct answer
Explanation
The break statement is used to exit from loops (for, while, do-while) and switch statements. It cannot be used with if statements because if is a conditional statement, not a loop. 'if loop' is incorrect terminology but the meaning is clear.
B
Correct answer
Explanation
The keyword public is an access modifier in languages like Java, C++, and C#, not a data type. Primitive types like int, object/component classes like button, and return types like void are all valid data types or type descriptors, making public the correct choice.
-
w var1
-
w this.var1
-
w ..var1
-
w ..#var1
-
w (classname).var1
D
Correct answer
Explanation
In Cache ObjectScript, the syntax ..#var1 is used to reference class parameters with indirection. The ## (double dot) operator provides access to class parameters, while the # symbol allows for parameter reference. Option w (write) is the command to output the value, making w ..#var1 the correct syntax for writing a class parameter value.
-
LENGTH
-
CONCAT
-
INSTR
-
NULLIF
B
Correct answer
Explanation
CONCAT can return non-NULL when passed NULL because it concatenates non-NULL values and ignores NULL arguments. For example, CONCAT('abc', NULL) returns 'abc'. LENGTH(NULL) returns NULL. INSTR with NULL returns NULL. NULLIF returns NULL if its arguments are equal, otherwise the first argument.
B
Correct answer
Explanation
Boolean values cannot be cast to other primitive types in Java. You cannot directly cast a boolean to int, char, or any other primitive type. You must use conditional logic or boolean expressions to convert boolean values to other types.
-
byte
-
String
-
integer
-
Float
A
Correct answer
Explanation
In Java, byte is a primitive data type. String is a class, integer is not a valid Java type (the primitive is int, and wrapper is Integer), and Float is a wrapper class, not a primitive.
-
byte
-
String
-
integer
-
Float
A
Correct answer
Explanation
In Java, primitive types are the basic data types built into the language: byte, short, int, long, float, double, char, boolean. String is a class (reference type). integer is not a valid Java type (it should be int). Float is a wrapper class, not a primitive (float is the primitive).
-
byte
-
String
-
integer
-
Float
A
Correct answer
Explanation
In Java, primitive types are the basic data types built into the language: byte, short, int, long, float, double, char, and boolean. Among the options, only 'byte' is a primitive type. 'String' is a class, 'integer' is not a valid keyword (the primitive is 'int'), and 'Float' is a wrapper class (the primitive is 'float').
-
scriptlets
-
declarations
-
implicit objects
-
expressions
C
Correct answer
Explanation
In JSP, implicit objects (also called predefined variables) are automatically available to JSP pages without declaration. These include request, response, session, application, out, config, page, and pageContext. They are called 'implicit' because the container creates them automatically - developers don't need to declare or instantiate them.
-
for
-
break
-
continue
-
Structure
D
Correct answer
Explanation
Java keywords are reserved words with specific meanings in the language. 'for', 'break', and 'continue' are built-in control flow keywords. 'Structure' is not a keyword in Java (unlike 'struct' in C/C++). Note that Java keywords are case-sensitive and lowercase.
-
Marks the beginning of one or more program control statements
-
Identifies the control card library
-
Delimits the PROC control statements
-
None of the above
A
Correct answer
Explanation
The //CNTL statement in JCL marks the beginning of one or more JCL control statements that will be interpreted by the system. It is used to introduce a section of control statements that need to be processed together. It is not specifically for identifying control card libraries (that would be different JCL constructs) or for delimiting PROC definitions (which use other statements).
-
Through the RC keyword
-
Through the COND keyword
-
Through the CODE keyword
-
Through the RETURNCD keyword
B
Correct answer
Explanation
The COND parameter in JCL is used to test return codes from previous job steps before executing the current step. It allows conditional execution based on success or failure of prior steps. RC, CODE, and RETURNCD are not valid JCL keywords - COND is the standard mechanism for conditional step execution based on return codes.
-
Linkage Variables
-
Control Libraries
-
Includes
-
Parameters
D
Correct answer
Explanation
JCL statements use parameters (both keyword and positional) to specify values directing statement execution, such as naming datasets or programs. Options like linkage variables, control libraries, and includes serve separate functions in program linkage or file organization.