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
-
Stream
-
Package
-
Class
-
None of these
A
Correct answer
Explanation
In Java I/O, a 'Stream' is the abstraction used for a sequence of data that can be produced (output) or consumed (input).
-
Their storage is temporary.
-
They hardly handle large amount of data.
-
They have storage permanent.
-
Both (1) and (2)
D
Correct answer
Explanation
Variables and arrays are stored in volatile memory (temporary) and are not suitable for handling large, persistent datasets.
-
The package definition must come first
-
Class should be private
-
Method should be without void
-
None of these
A
Correct answer
Explanation
Java source files follow a strict ordering rule where the package statement must be the first non-comment line. In the provided code, import statements appear before the package declaration, which will cause a compiler error. To fix this, the package student; line must be moved to the top of the file.
-
read from stream
-
write to the stream
-
both (1) and (2)
-
none of these
C
Correct answer
Explanation
Filter streams in Java are designed to wrap existing streams to provide additional functionality, such as buffering or data transformation. They can perform these filtering operations on data as it is being read from or written to the underlying stream.
-
position dependent
-
position independent
-
location dependent
-
none of these
B
Correct answer
Explanation
Position-independent code (PIC) is machine code that executes correctly regardless of its absolute address in memory, which is essential for shared libraries.
-
Static
-
Dynamic
-
Both 1 and 2
-
None of these
B
Correct answer
Explanation
Dynamic relocation is performed at runtime, meaning the address mapping can change while the process is running.
-
mutable files
-
Immutable files
-
Transactions
-
None of these
C
Correct answer
Explanation
The all-or-nothing property, also known as atomicity, is a fundamental characteristic of transactions in database and distributed systems.
-
Immutable
-
Mutable
-
Both 1 and 2
-
None of these
A
Correct answer
Explanation
An immutable object or file is one whose state cannot be modified after it is created. This is a common concept in functional programming and distributed file systems.
-
final
-
super
-
instance of
-
implicit
C
Correct answer
Explanation
The 'instanceof' operator in Java checks if an object is an instance of a specific class or implements a specific interface.
-
Static
-
Switch
-
Main
-
Import
C
Correct answer
Explanation
Static, Switch, and Import are reserved keywords in Java. Main is just a method name, not a reserved keyword.
-
arguments by reference
-
arguments by value
-
arguments by pointer
-
arguments by variable
B
Correct answer
Explanation
Java always passes arguments by value. For objects, the value passed is the reference to the object.
-
Float
-
Char
-
Double
-
Return
-
Void
B
Correct answer
Explanation
It is an integral data type because it stores the ASCII value of any character constant.
-
Array
-
Union
-
Structure
-
Function
-
Void
B
Correct answer
Explanation
Union creates a memory overlay area, with each union member using same memory storage locations.
-
Do while
-
While
-
For
-
Break
-
Goto
A
Correct answer
Explanation
This loop is called exit controlled loop because the condition is checked in the end, in do while loop.
-
compile time
-
run time
-
execution time
-
none of these
A
Correct answer
Explanation
Static variables or global variables (often referred to as S in such contexts) are allocated memory at compile time.