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
-
+public
-
#protected
-
!package
-
-private
B
Correct answer
Explanation
In UML class diagrams, visibility symbols are: + (public), - (private), # (protected), and ~ (package/default). Option B claims # represents protected, but # actually IS the correct UML symbol for protected. The question asks for the WRONG pair, and + for public, ! for package, and - for private are all correct. Only # for protected is correctly represented, making B the wrong statement if it claimed otherwise.
-
typset x=32+8
-
set x=32+8
-
let x=32+8
-
x=32+8
C
Correct answer
Explanation
In Unix shells like KornShell (ksh), the let command is used for arithmetic evaluation. let x=32+8 evaluates the expression and assigns the integer value 40 to the variable x.
-
typset x=32+8
-
set x=32+8
-
let x=32+8
-
x=32+8
C
Correct answer
Explanation
In shell scripting, 'let' is used for arithmetic operations. The command 'let x=32+8' evaluates the arithmetic expression 32+8 and assigns the result 40 to variable x. Option A uses 'typset' which is a typo for 'typeset' (used for variable declaration), Option B 'set' is for shell options/parameters, and Option D is just a string assignment in most shells.
B
Correct answer
Explanation
Static variables belong to the class itself rather than to any instance. They are not serialized because serialization is meant to save the state of individual objects, and static variables represent shared class-level state. Serializing them would duplicate shared state across deserialized instances, breaking the design.
-
isNumber()
-
isString()
-
typeof()
-
Option 1 & 2
C
Correct answer
Explanation
The typeof operator in JavaScript returns a string indicating the type of the operand's value. It can return 'number', 'string', 'boolean', 'undefined', 'object', or 'function'. Functions like isNumber() and isString() are not built-in JavaScript functions.
-
Mode value is 1Mode value is 2Mode value is 3
-
Mode value is 1
-
JavaScript error in the browser
-
None of the above
A
Correct answer
Explanation
This switch statement lacks break statements, so it exhibits fall-through behavior. Once mode matches case 1, execution continues through case 2 and case 3, printing all three messages. Without break statements, every case after the matching one executes.
D
Correct answer
Explanation
C++ programs conventionally return 0 to the operating system to indicate successful execution, following a universal programming standard. Non-zero return values typically signal errors or specific exit conditions. This convention allows scripts and other programs to programmatically detect whether a program completed successfully.
-
Inline functions
-
virtual functions
-
Both A and B
-
None of the above
A
Correct answer
Explanation
Inline functions eliminate function call overhead by inserting the function's code directly at each call point during compilation, rather than using a standard function call mechanism. This optimization is particularly useful for small, frequently-called functions. Virtual functions enable polymorphism through dynamic dispatch and are not inlined by default.
A
Correct answer
Explanation
C++ functions can return only one value directly through the return statement. Multiple values can be returned indirectly using pointers, references, or by wrapping them in a struct/class.
-
conditional statement
-
assignment statement
-
looping statement
-
None of the Above
B
Correct answer
Explanation
Assignment statements using the = operator assign values to variables in C++. Conditional statements (if/else) control flow, and looping statements (for/while) repeat code blocks - none directly assign values.
-
release
-
deallocate
-
delete
-
all the above
C
Correct answer
Explanation
The delete operator releases dynamically allocated memory in C++. It's used for memory allocated with new. For arrays, delete[] is used. There's no standard "release" or "deallocate" keyword in C++.
-
Data Hiding
-
Encapsulation
-
Operator Overloading
-
None Of the Above
C
Correct answer
Explanation
The standard C++ input/output streams cin and cout utilize operator overloading. Specifically, the bitwise left shift << and right shift >> operators are overloaded as insertion and extraction operators to perform stream I/O operations.
-
LinkedList<integer> l=new LinkedList<int>();
-
List<number> l=new LinkedList<number>();
-
LinkedList<integer> l=new LinkedList();
-
LinkedList<integer> l=new <integer>LinkedList()
-
List<number> l=new LinkedList<integer>();
-
two, two, one
-
two, three, one
-
two, two, three
-
two, two, two
C
Correct answer
Explanation
In SAS macros, &one resolves to 'two' (first PUT). &&one triggers double resolution - it resolves &one to 'two', then resolves &two to 'three' (second PUT). &&&one is triple resolution - &one to 'two', &two to 'three', &three to 'one' (third PUT). The output is: two, two, three. Option C is correct.
-
holds the input record for the next INPUT statement to read in the same iteration of the DATA step
-
holds the input record for the next INPUT statement to read across further iterations of the DATA step
-
holds the input record for the current input statement to read across further iterations of the DATA step
-
All of the above
A
Correct answer
Explanation
The single trailing at-sign (@) is a line hold specifier that keeps the input buffer in the current iteration, allowing the next INPUT statement in the same DATA step iteration to continue reading from the same record. It does NOT hold across iterations (that would be double trailing @@). Option A correctly describes this behavior.