StudyFox
कीमतेंब्लॉगएक्सटेंशनमुफ़्त टूल
  • कीमतें
  • ब्लॉग
  • एक्सटेंशन
  • मुफ़्त टूल
  • शुरू करेंसाइन इन
StudyFox

अपने नोट्स, PDF और स्लाइड्स को फ़्लैशकार्ड, क्विज़, नोट्स और माइंड मैप में बदलें।

StudyFox खोलें

स्टडी टूल्स

  • होमवर्क हेल्पर
  • नोट मेकर
  • फ़्लैशकार्ड मेकर
  • क्विज़ मेकर
  • माइंड मैप मेकर

प्रोडक्ट

  • कीमतें
  • Chrome एक्सटेंशन
  • मुफ़्त एक्सटेंशन
  • स्टडी सेट देखें
  • ब्लॉग

सहायता

  • सहायता केंद्र
  • संपर्क करें
  • गोपनीयता नीति
  • सेवा की शर्तें

तुलना करें

  • Chegg का विकल्प
  • Course Hero का विकल्प
  • Coursology का विकल्प
  • Photomath का विकल्प
  • Gauthmath का विकल्प
  • PhotoSolve का विकल्प
  • CollegeTools का विकल्प
  • Transcript का विकल्प
  • SmartSolve का विकल्प
  • Homeworkify का विकल्प
  • AnswersAi का विकल्प
  • StudyX का विकल्प
  • Quizlet का विकल्प
  • Anki का विकल्प
  • Knowt का विकल्प
  • Brainscape का विकल्प
  • सभी तुलनाएँ

© 2026 StudyFox AI. सर्वाधिकार सुरक्षित।

  • X
  • Discord
  • Instagram
ExploreEngineering & TechComputer ScienceProgramming Fundamentals Quiz: Types, Memory, Data and OOP Concepts

Quiz · Medium

Programming Fundamentals Quiz: Types, Memory, Data and OOP Concepts

Twenty questions on typing, compilers, the call stack, memory, number and text representation, Python semantics and object-oriented principles.

by Kill h.20 questionsCreated Nov 20, 2026, 08:27 PM
Computer Science· ProgrammingTags#programming#fundamentals#python#quiz

20 questions

  1. 1

    Which pair describes Python's typing discipline?

    • A

      Static and weak

    • B

      Static and strong

    • Dynamic and strong

    • D

      Dynamic and weak

    Python checks types at run time (dynamic) and refuses mixing unrelated types such as '3' + 4 (strong).

  2. 2

    Which phase of compilation turns a stream of tokens into a tree that reflects the program's structure?

    • Parsing

    • B

      Lexing

    • C

      Code generation

    • D

      Linking

    The lexer produces tokens; the parser builds the syntax tree (like the one shown); later phases generate code.

  3. 3

    The abstract syntax tree in the picture is for which loop?

    • A

      A for loop summing numbers

    • B

      A recursive factorial

    • C

      Binary search

    • Euclid's algorithm by subtraction: while b != 0, subtract the smaller from the larger, return a

    The root has a while node (condition b ≠ 0) with a branch comparing a > b and subtracting, and returns a. Image: Dcoetzee, CC0, via Wikimedia Commons.

  4. 4

    What does -7 // 2 evaluate to in Python?

    • A

      -3

    • -4

    • C

      3

    • D

      -3.5

    Floor division rounds toward negative infinity: −3.5 floors to −4. Truncation (as in C) would give −3.

  5. 5

    What does bool('0') return in Python?

    • A

      False

    • B

      Error

    • True

    • D

      None

    Any non-empty string is truthy, including '0'. Only '' is falsy.

  6. 6

    What is printed?

    a = [1, 2]
    b = a
    b.append(3)
    print(a)
    • [1, 2, 3]

    • B

      [1, 2]

    • C

      [3]

    • D

      Error

    b = a makes both names refer to the same list. Appending through b changes what a sees.

  7. 7

    What is the result of round(3.5) and round(2.5) in Python 3?

    • A

      4 and 3

    • B

      3 and 2

    • C

      3 and 3

    • 4 and 2

    Python 3 uses banker's rounding: halves round to the nearest even integer, so 3.5 → 4 and 2.5 → 2.

  8. 8

    In the call-stack diagram, what is stored between the parameters and the locals of a frame?

    • A

      The heap pointer

    • The return address

    • C

      The global variables

    • D

      The next function's code

    The return address tells the CPU where to continue in the caller once this function returns.

  9. 9

    Which statement about stack and heap memory is correct?

    • A

      The heap is faster and always smaller

    • B

      Local variables always live on the heap

    • Stack allocation is automatic and LIFO; heap allocation has a flexible lifetime

    • D

      Heap memory is freed automatically on function return

    Stack frames are pushed and popped as functions are called and return. Heap objects live until freed or garbage-collected.

  10. 10

    Why does CPython need a cycle collector in addition to reference counting?

    • Objects that reference each other keep non-zero counts even when unreachable

    • B

      Reference counting is too slow

    • C

      Counting only works for integers

    • D

      The stack overflows otherwise

    Two objects referring to each other never reach a count of zero; the cycle collector finds such unreachable groups.

  11. 11

    What are the ASCII codes (decimal) of 'A' and 'a'?

    • A

      97 and 65

    • B

      64 and 96

    • C

      65 and 98

    • 65 and 97

    'A' = 65 and 'a' = 97, a difference of 32 (a single bit). Image: Klaas van Buiten, CC BY-SA 4.0, via Wikimedia Commons.

  12. 12

    What is 5 ^ 3 in Python?

    • A

      8

    • 6

    • C

      15

    • D

      2

    ^ is bitwise XOR: 101 XOR 011 = 110 = 6. The power operator is **.

  13. 13

    Why does 0.1 + 0.2 == 0.3 evaluate to False in most languages?

    • A

      Python has a bug with decimals

    • B

      The == operator only compares integers

    • 0.1 and 0.2 cannot be represented exactly in binary floating point

    • D

      Addition always loses precision

    The stored values are approximations; their sum is 0.30000000000000004. Use math.isclose or the decimal module.

  14. 14

    A 32-bit signed integer holds 2,147,483,647. In C, what is the typical result of adding 1?

    • It wraps to −2,147,483,648

    • B

      It becomes 2,147,483,648

    • C

      It becomes 0

    • D

      The program always crashes

    Two's complement wraps around (formally undefined behavior for signed types). Python integers never overflow.

  15. 15

    In the endianness diagram, how does a little-endian machine store a 32-bit number compared with a big-endian one?

    • A

      Bits reversed within each byte

    • B

      Same order but different address range

    • C

      Bytes sorted alphabetically

    • Bytes in reverse order, least significant byte first

    Little-endian places the least significant byte at the lowest address. The bytes themselves are not bit-reversed. Image: Daniele Giacomini, CC BY-SA 2.5, via Wikimedia Commons.

  16. 16

    Which OOP principle lets one interface (for example shape.area()) run different code for different object types?

    • A

      Encapsulation

    • Polymorphism

    • C

      Abstraction only

    • D

      Serialization

    Polymorphism: the same call dispatches to each subclass's own implementation.

  17. 17

    Which principle says a class should have only one reason to change?

    • A

      Open/closed

    • B

      Liskov substitution

    • Single responsibility

    • D

      Interface segregation

    The S in SOLID.

  18. 18

    True or false: a closure in Python can modify an enclosing variable without any declaration.

    • A

      True

    • False

    Assigning to a variable in an enclosing function requires nonlocal; otherwise Python creates a new local variable.

  19. 19

    True or false: finally runs even when the try block contains a return statement.

    • True

    • B

      False

    The finally block always executes before the function actually returns.

  20. 20

    What does the C++ snippet in the figure do with **newPtr = 33; after newPtr = &myPtr?

    • Changes the value of myVar to 33

    • B

      Changes the pointer myPtr

    • C

      Declares a new variable

    • D

      Frees myVar

    Dereferencing twice follows newPtr → myPtr → myVar and writes 33 into myVar. Image: Pat McClanahan, CC BY-SA 4.0, via Wikimedia Commons.