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
Correct answer
Explanation
The finally block will not execute because the try block contains either an infinite while(true) loop (never exits) or System.exit(1), which terminates the JVM immediately. In Java, System.exit() bypasses all exception handling and finally blocks.
-
?:(Ternary Operator)
-
.(member access)
-
() (Paranthesis)
-
::(scope resolution)
A,B,D
Correct answer
Explanation
In C++, the ternary operator (?:), member access operator (.), and scope resolution operator (::) cannot be overloaded. These operators have fundamental meanings that must remain consistent. Function call operator () can be overloaded, which is why option C is incorrect.
-
gettype()
-
is_double()
-
get_type()
-
is_date()
-
A&B
E
Correct answer
Explanation
PHP provides gettype() to determine a variable's type and is_double() as an alias for is_float() to specifically check for double/float types. Both functions serve type detection purposes, though is_double() is a deprecated alias for is_float(). The get_type() option is incorrect due to underscore placement, and is_date() is not a standard PHP function.
-
$# will print the same
-
$? will print the same
-
$! will print the same
-
$$ will print the same
A
Correct answer
Explanation
In shell scripting, $# expands to the number of positional parameters passed to the script. Meanwhile, $? holds the exit status of the last executed command, $! contains the process ID of the most recent background command, and $$ represents the current shell's process ID.
B
Correct answer
Explanation
Bitwise operations in Java have different precedence levels. For example, & has higher precedence than ^, which has higher precedence than |. They are not all at the same level. The statement claiming 'same level of precedence' is false.
B
Correct answer
Explanation
When searching for objects in MicroStrategy, you can select multiple object types simultaneously in the search dialog. The interface allows you to check multiple object type checkboxes (Reports, Documents, Metrics, Filters, etc.) to search across all selected types in a single operation, rather than being limited to one type at a time.
D
Correct answer
Explanation
In C++, the keyword bool is used to declare variables that hold Boolean values (true or false). Distractors like boolean are used in other languages such as Java, while boo and bolean are misspelled or non-existent keywords in C++ syntax.
B
Correct answer
Explanation
Java does not have a preprocessor like C/C++. Java was designed without preprocessing features such as #define, #include, or conditional compilation to maintain platform independence and simplify the language. Compilation and preprocessing are handled differently in Java.
A
Correct answer
Explanation
In standard C++ (before std::string), there is no built-in string type - strings are implemented as char arrays or pointers. The std::string class is a library implementation, not a primitive language type. Modern C++ has string in the standard library, but it's still not a fundamental type like int or char.
-
int i = 0XCAFE;
-
boolean b = 0;
-
char c = A;
-
byte b = 128;
-
char c = "A";
A
Correct answer
Explanation
Option A is valid: '0XCAFE' is a hexadecimal literal (hex digits start with 0X or 0x). Option B is invalid: boolean can only be 'true' or 'false', not 0. Option C is invalid: 'A' must be quoted as a character literal. Option D is invalid: byte range is -128 to 127, 128 overflows. Option E is invalid: char can't take a String literal.
B
Correct answer
Explanation
This code is illegal because you cannot assign an int array to a long array reference. Even though long can hold int values, array types are not compatible - an int[] is not a subtype of long[]. You would need to create a new long array and copy elements individually.
-
datetime
-
decimal
-
void
-
number
D
Correct answer
Explanation
Ab Initio's valid datatypes include datetime, decimal, and various numeric types, but does not have a generic "number" datatype. The correct numeric types are specific types like int, decimal, float, etc. "void" is typically used in programming languages but not as a datatype in Ab Initio's DML.
-
A conditional field must not contain a reference to either a lookup function or a global variable.
-
Although DML syntax allows you to include a function field as part of a conditional field, the function field is not conditional and works the same way whether or not the condition is met.
-
A record type cannot declare nullable and conditional fields at the same time.
-
A conditional field can share a delimiter with the record.
-
For a conditional field to be nullable, it must have a default value.
D
Correct answer
Explanation
This question asks which statement about conditional DML is FALSE. The correct answer is D because conditional fields CANNOT share delimiters with the record - each conditional field must have its own delimiter specification. Options A, B, C, and E are all true statements about conditional DML fields in Ab Initio.
-
String
-
Char
-
Decimal
-
Integer
B
Correct answer
Explanation
In Ab Initio DML, valid types include string, decimal, integer, date, datetime, and others. 'char' is NOT a valid DML type in Ab Initio - the correct type for character data is 'string' (or 'vector(string)' for arrays). Char might be confused with SQL character types, but Ab Initio DML uses 'string' instead.
-
a. The switch and case statement
-
b. ternary operator
-
c. nested if statement
-
d. The #endif statement
A
Correct answer
Explanation
The switch-case statement replaces multiple if-else statements when comparing a single expression against many constant values. This improves readability and can be more efficient. Ternary operators only replace simple if-else, and nested ifs are the opposite of simplification.