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
-
None; the statement is skipped.
-
The THEN part of the statement is executed.
-
The ELSE part of the statement is executed.
-
Both the THEN and the ELSE parts of the statement are executed.
B
Correct answer
Explanation
In an IF-THEN-ELSE structure, when the condition evaluates to true, only the THEN clause is executed. The ELSE clause is skipped entirely.
-
logic
-
syntax
-
pseudocode
-
debugging
A
Correct answer
Explanation
A logic error occurs when the algorithm or reasoning is wrong, even if the code is syntactically correct. Using addition instead of multiplication for area is a conceptual mistake in the problem-solving approach, not a syntax violation.
-
string, numeric
-
numeric, string
-
character, string
-
indexed, string
A
Correct answer
Explanation
Student names consist of text characters and must be stored in string arrays to preserve the text format. Prices represent numerical values and are stored in numeric arrays for arithmetic operations. This distinction is fundamental in programming - strings for text, numbers for calculations.
-
a DO WHILE...LOOP
-
a FOR...NEXT loop
-
two nested FOR...NEXT loops
-
a DO UNTIL...LOOP statement
C
Correct answer
Explanation
A two-dimensional array has rows and columns, requiring two separate loops to access all elements systematically. The outer loop iterates through rows, while the inner loop iterates through columns. This nested structure ensures every element in the 2D grid is processed exactly once.
-
constant
-
character string
-
variable
-
number
C
Correct answer
Explanation
A variable is a named storage location that holds values which can be modified during program execution. Unlike constants, variables allow programs to work with changing data. This fundamental concept enables dynamic programming and data manipulation.
-
concurrency
-
conception
-
configure
-
concatenation
D
Correct answer
Explanation
Concatenation is the operation of joining two or more strings end-to-end to create a single combined string. This is a fundamental string operation in programming, used extensively in text processing, formatting output, and building file paths. The term comes from Latin meaning 'to link together'.
-
Syntactic error debugging in a program is the process of identifying and correcting errors.
-
Run-time or logical error debugging in a program is the process of identifying and correcting errors.
-
Debugging through the Internet is the process of downloading a large file.
-
Debugging is the process of defragmenting a hard disk.
-
None of these
-
varray
-
nested table
-
record
-
index-by tables
C
Correct answer
Explanation
A PL/SQL record is a group of related data items. For example, the data about a student like roll no., name, date of birth are logically related to each other but have different types. A record containing a field for each item lets the user treat the data as a logical unit. Thus, making it easier to organise and represent. The syntax for creating a record is
type type_name is record (fielddeclaration1,fielddeclaration2...);
-
INVALID_CURSOR
-
OPEN_CURSOR
-
CURSOR_ALREADY_OPEN
-
CURSOR_IS_OPEN
C
Correct answer
Explanation
The CURSOR_ALREADY_OPEN exception is thrown when we are trying to open a cursor that is already open. A cursor cannot be opened twice without closing it first.
-
Procedure can be called from SQL prompt, while function cannot be called from SQL prompt.
-
Function can return a value, while procedure cannot return any value.
-
Functions can have arguments, while procedure cannot have arguments.
-
Function can call procedures while procedure cannot call functions.
B
Correct answer
Explanation
The difference between a function and procedure is that a function can return a value to its calling function while a procedure cannot return a value. Function returns a value using the 'return' keyword. A function cannot return more than one value.
-
Declare
-
Begin
-
Return
-
Exception
A
Correct answer
Explanation
The declaration section of a PL/SQL program is used to contain all variable declarations. While using a function, the declare keyword is replaced by 'is' keyword. All the variables are declared inside the 'is' keyword. For example,
CREATE OR REPLACE FUNCTION myfunc
RETURN VARCHAR(20);
IS
sname VARCHAR(20);
BEGIN
SELECT studname INTO sname
FROM students WHERE rollno = 1;
RETURN sname;
END;/
-
Modularity
-
Reusability
-
Abstraction
-
Inheritance
D
Correct answer
Explanation
There is no inheritance in subprogram and therefore it cannot be counted as one of its advantages.
-
The mode of a parameter can be both IN and OUT.
-
A cursor parameter can be assigned a default value.
-
The scope of the cursor parameter is local to the cursor.
-
We can only specify the datatype of the parameter, not its length.
A
Correct answer
Explanation
Parameterized cursors are static cursors that can accept passed-in parameter values when they are opened. The mode of parameter passed to a cursor can only be IN. The syntax for opening a parameterized cursor is
open cursor_name(value)
Example:
open mycursor(1000);
where 1000 is the parameter value
-
enumeration
-
int
-
type def
-
float
C
Correct answer
Explanation
This data type allows an user to define his own identifier to represent an existing data type in 'C'.
-
strcmp()
-
strncmp()
-
strncpy()
-
none of these
B
Correct answer
Explanation
This function in 'C' compares the first n characters of two input strings.