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
-
Any changes made to the parameter will be reflected in the variable.
-
The out parameters is used to return values in the same variables, that you pass an an argument of a method
-
A variable to be sent as OUT parameter must be initialized
-
1 & 2
-
2 & 3
-
1 & 3
D
Correct answer
Explanation
In C#, OUT parameters allow methods to return values through the same variables passed as arguments. Any changes to the parameter are reflected in the calling variable, and importantly, variables passed as OUT do NOT need to be initialized before being passed (unlike 'ref' parameters).
-
print([int] 100 )
-
print (Val("100"))
-
iTemp = INTEGER(100)
-
INTEGER iTemp = Val ("100")
D
Correct answer
Explanation
In 4Test (SilkTest's language), to convert a string to an integer, you declare an INTEGER variable and use the Val() function. The syntax 'INTEGER iTemp = Val("100")' correctly declares the variable and converts the string "100" to its numeric value. Options A, B, and C have incorrect syntax for 4Test.
B
Correct answer
Explanation
The SIMPLE_INTEGER datatype in Oracle (introduced in 11g) is a subtype of PLS_INTEGER that does not allow NULL values. It's designed for performance-critical code where NULL handling overhead is unwanted. SIMPLE_INTEGER always ranges from -2,147,483,648 to 2,147,483,647 and cannot be NULL.
B
Correct answer
Explanation
System.Array is a strongly-typed collection in .NET. When you declare an array, you must specify the type of elements it will contain (e.g., int[] or string[]). Once declared, an array can only store elements of that specific type. To store multiple types, you'd need an object[] or an ArrayList/collection.
A
Correct answer
Explanation
True is correct because when an exception is thrown in a try block, only the first matching catch block will execute. Once a catch block handles the exception, control passes to that block and subsequent catch blocks are skipped. This is why catch blocks must be ordered from most specific to most general exception types to ensure the correct handler is chosen.
-
DC
-
DS
-
No Such Instruction Exists
-
1 and 2
A
Correct answer
Explanation
DC (Define Constant) is used to allocate memory and initialize it with a constant value in assembler. DS (Define Storage) only reserves memory space without initialization. Therefore DC is the instruction that both allocates and initializes memory.
-
Handle with try catch block
-
Handle with Throwable class
-
Both of above true
-
None of above
D
Correct answer
Explanation
Compile-time errors (checked exceptions) must be handled at compile time through declaration or catching. They cannot be handled with try-catch at runtime because the compiler enforces their handling before the code can run. Throwable is the superclass of all errors and exceptions but doesn't apply here.
-
Finding length of string
-
Clearing elements in Vector
-
Comparing two Strings
-
None of above
C
Correct answer
Explanation
The intern() method in Java's String class is used to return a canonical representation of the string from the string pool. It's primarily used for string comparison optimization - interned strings can be compared using == reference equality instead of equals() for content comparison.
-
Package and function
-
Function and userexit
-
Procedure and package
-
Function and procedure
D
Correct answer
Explanation
In relational database systems like DB2, routine objects include user-defined functions and procedures. Packages are compiled objects containing SQL statements, not routines themselves, while userexits are external programs for task-specific processing rather than standard routine objects.
B
Correct answer
Explanation
Nested functions are NOT allowed in standard C. While some compilers (like GCC) support nested functions as an extension, they are not part of the C language standard. C was designed to be a simple language with functions that can only be defined at file scope, not inside other functions.
A
Correct answer
Explanation
This is the correct syntax for declaring a function pointer in C. 'int (*pt2Function) (float, char, char)' declares pt2Function as a pointer to a function that takes a float and two char parameters and returns an int. The parentheses around *pt2Function are crucial - they make it a pointer to a function rather than a function returning a pointer.
A
Correct answer
Explanation
Two function pointers can indeed be compared using the == operator. This checks if they point to the same function address. If both pointers point to the same function, the comparison returns true; otherwise, it returns false. This is valid and commonly used in C programming.
-
Ruby On Rail
-
Windows
-
Linux
-
Mac
-
Chrome
-
Solories
A
Correct answer
Explanation
Ruby on Rails is a web application framework for building websites, not an operating system. Windows, Linux, Mac, Chrome OS, and Solaris are operating systems that manage computer hardware and software.
-
Code Area
-
Data Area
-
Stack Area
-
Heap Area
C
Correct answer
Explanation
In Java's memory model, local primitive variables and local reference variables are stored in the Stack Area. Each thread has its own stack, where method frames containing local variables and partial results are pushed when methods are invoked. The Heap stores objects, Code Area stores bytecode, and Data Area stores static/class variables.
-
the use of a variable before it has been defined
-
unreachable (“dead”) code
-
memory leaks
-
array bound violations
C
Correct answer
Explanation
Static analysis analyzes source code without executing it. It can find syntax errors, dead code, undefined variables, and array bound violations. However, memory leaks are dynamic run-time anomalies that static analysis cannot reliably identify, requiring dynamic execution to detect accurately.