Independent Preparation Bank for Pakistani Computing Graduates • 100% Free • No Signup
NSCTPrep.
Programming (C++ / Java / Python)Topic #1 of 548 MCQs Available

Programming Fundamentals

Comprehensive question bank, step-by-step rationales, and dedicated timed quiz for Programming Fundamentals.

Launch Quiz Mode ↗

Programming Fundamentals Question Bank

Showing 48 questions of 48 with verified answers

1Multiple Choice

(Conceptual) In the software build process, which stage is responsible for combining multiple object files and libraries into a single executable file?

2Multiple Choice

(Comparison) A language that requires you to declare int x = 5; and throws an error if you try to assign x = "Hello"; later is best described as:

3Multiple Choice

(Scenario-Based) A developer is writing a high-performance graphics engine where every millisecond of CPU time matters. Which type of language should they prioritize?

4Multiple Choice

(Code-Tracing / Logic) In a Weakly Typed language like JavaScript, what is the likely result of the expression: "5" + 2?

5Multiple Choice

(Conceptual) Which programming paradigm is built around the concept of "Pure Functions" that do not have side effects or shared state?

6Multiple Choice

(Debugging) During compilation, the compiler finds a line of code: if (x == 5) { y = 10 } but notices the closing ) is missing. Which phase of the compiler detects this?

7Multiple Choice

(Comparison) What is the primary advantage of a Managed Language (like Java or C# with a Virtual Machine/CLR) over an Unmanaged Language (like C++)?

8Multiple Choice

(Scenario-Based) You are creating a small script to automate a file-renaming task that will only be run once. You want to write it quickly without a "Build/Compile" step. Which type of language is best?

9Multiple Choice

(Conceptual) What is the role of a "Virtual Machine" (like the JVM) in the execution of a program?

10Multiple Choice

(Code Output / Logic) Trace the logic in this pseudocode: x = "100" y = 50 print(x + y) If the language is Strongly Typed (like Python), what happens?

11Multiple Choice

(Conceptual) In the context of programming paradigms, "Encapsulation" is a core principle of which paradigm?

12Multiple Choice

(Scenario-Based) A developer is writing code for a microcontroller with very limited RAM (only 2KB). Which language feature should they avoid to prevent crashing?

13Multiple Choice

(Comparison) What is a Transpiler (Source-to-Source Compiler)?

14Multiple Choice

(Conceptual) What is "Semantic Analysis" in the compilation process?

15Multiple Choice

(Scenario-Based) You are using a language that uses a Just-In-Time (JIT) compiler. When does the actual machine code generation happen?

1Multiple Choice

(Conceptual) In memory management, where are Primitive variables usually stored compared to Reference objects? • • • •

2Multiple Choice

(Code-Tracing) What is the output of the following C++/Java code? double myValue = 9.99; int result = (int) myValue; print(result);

3Multiple Choice

(Scenario-Based) You are designing a system to store the population of the world (approx. 8 billion). Which data type is the most appropriate to prevent overflow?

4Multiple Choice

(Debugging) A developer writes: float price = 19.99; in Java/C#. The compiler throws an error: "Incompatible types: possible lossy conversion from double to float." Why?

5Multiple Choice

(Conceptual) What is the effect of the static keyword on a variable declared inside a class?

6Multiple Choice

(Code-Tracing) Trace this logic: int a = 127; byte b = (byte) a; b++; print(b); Assuming a standard 8-bit signed byte (-128 to 127):

7Multiple Choice

(Scenario-Based) An application needs to represent four specific states of an order: PENDING, SHIPPED, DELIVERED, CANCELLED. What is the most type-safe way to represent this?

8Multiple Choice

(Comparison) What is the difference between NULL (C++) and null (Java/C#)?

9Multiple Choice

(Conceptual) Why are String objects "Immutable" in languages like Java and Python?

10Multiple Choice

(Code-Tracing) What is the output of this code? char c = 'A'; print(c + 1); Assuming 'A' has an ASCII value of 65:

11Multiple Choice

(Scenario-Based) You are calculating the interest on a bank account with 10 million users. Using float for the balance results in a discrepancy of $50,000 across the whole system. What is the cause?

12Multiple Choice

(Conceptual) What is a "Wrapper Class" in Java (e.g., Integer for int)?

13Multiple Choice

(Comparison) What is the difference between const and readonly in C#?

14Multiple Choice

(Code-Tracing) What is the value of result? int x = 10; float y = 4.0f; auto result = x / y; (Using C++/Java logic where auto or var infers the type)

15Multiple Choice

(Conceptual) Which of the following is an example of an "Unsigned" data type violation?

1Multiple Choice

(Code-Tracing) What is the final value of z? • • • • int x = 5; int y = 2; int z = x / y * y;

2Multiple Choice

(Code-Tracing) Trace the value of x and y: int x = 10; int y = x++;

3Multiple Choice

(Scenario-Based) Which operator is best used to check if a specific number N is a multiple of 10?

4Multiple Choice

(Debugging) Trace the following logic: int count = 0; if (true || (++count > 0)) { print(count); }

5Multiple Choice

(Calculation) What is the result of the bitwise XOR (^) operation on 5 and 3?

6Multiple Choice

(Code-Tracing) What will be printed? int x = 10; int y = 20; print(x > 5 && y < 15 ? "Alpha" : "Beta");

7Multiple Choice

(Conceptual) What does performing a Bitwise Left Shift (<<) by 2 positions do to an integer?

8Multiple Choice

(Code-Tracing) Trace the value of val: int val = 8; val >>= 2;

9Multiple Choice

(Comparison) What is the difference between & and && in Java/C#?

10Multiple Choice

(Calculation) Evaluate the expression: 10 + 5 * 2 == 20

11Multiple Choice

(Scenario-Based) A developer needs to swap two integers a and b without using a third temporary variable. Which bitwise operator can achieve this?

12Multiple Choice

(Debugging) Trace this code snippet: int x = 5; if (x = 0) { print("Zero"); } else { print("Non-Zero"); } In C/C++, what is the output?

13Multiple Choice

(Code-Tracing) Trace the output: int i = 5; int j = ++i + i++; print(j);

14Multiple Choice

(Conceptual) Which operator has the lowest precedence in most programming languages?

15Multiple Choice

(Code-Tracing) Trace the value of ans: int ans = 10 % 3 + 4 << 1;

1Multiple Choice

(Code-Tracing) What is the output of the following C++/Java code? • • • • int x = 2; switch (x) { case 1: print("A"); case 2: print("B"); case 3: print("C"); default: print("D"); }

2Multiple Choice

(Debugging) A developer wants a loop that runs exactly 10 times. Which of the following contains a logical error?

3Multiple Choice

(Code-Tracing) How many times will "Hello" be printed? for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { if (i == j) continue; print("Hello"); } }