Software Engineering Lecture 2: Object-Oriented Programming Concepts in Python
30 Questions
1 Views

Software Engineering Lecture 2: Object-Oriented Programming Concepts in Python

Created by
@BrighterTone

Podcast Beta

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which OOP concept involves creating objects from classes?

  • Instantiation (correct)
  • Encapsulation
  • Abstraction
  • Polymorphism
  • What does encapsulation describe in object-oriented programming (OOP)?

  • Encapsulation is the process of creating objects from classes.
  • Encapsulation means object instantiation and accessing instance attributes.
  • Encapsulation is the idea of wrapping data and the methods that work on data within one unit. (correct)
  • Encapsulation refers to the inheritance principle and how to inherit a class.
  • What does inheritance principle refer to in OOP?

  • It refers to the process of object instantiation.
  • It refers to the idea of wrapping data and methods within one unit.
  • It refers to the process of creating classes.
  • It refers to the ability of objects to have a mix of inherited and unique methods. (correct)
  • What is the purpose of class abstraction in OOP?

    <p>Class abstraction involves hiding the complex implementation details and showing only the necessary features of the object.</p> Signup and view all the answers

    What does polymorphism allow objects to have in OOP?

    <p>A mix of some inherited methods and some unique to their own class.</p> Signup and view all the answers

    In OOP, what describes the idea of wrapping data and methods within one unit?

    <p>Encapsulation</p> Signup and view all the answers

    What is the purpose of encapsulation in object-oriented programming?

    <p>To prevent accidental modification of data by restricting access to variables and methods</p> Signup and view all the answers

    In C#, which access specifier allows class members to be accessed from anywhere in the code?

    <p>Public</p> Signup and view all the answers

    What is the role of the underscore symbol in Python with regards to access control?

    <p>Indicates a private data member or member function of a class</p> Signup and view all the answers

    Which type of variable in Python is easily accessible from any part of the program?

    <p>Public variable</p> Signup and view all the answers

    What does the 'protected' access specifier in C# allow?

    <p>Access only within the class or in child/derived classes</p> Signup and view all the answers

    Which programming languages use access specifiers to define the scope and visibility of a class and its members?

    <p>Both C# and Python</p> Signup and view all the answers

    What is the primary role of access specifiers in programming languages?

    <p>To restrict access to class members and control visibility</p> Signup and view all the answers

    Which type of variable can only be accessed within the class in C#?

    <p>Private variable</p> Signup and view all the answers

    What is the fundamental building block for constructing software in functional programming?

    <p>Functions</p> Signup and view all the answers

    In functional programming, what are functions treated as?

    <p>First-class objects</p> Signup and view all the answers

    Which type of functions does functional programming emphasize?

    <p>Pure functions without side effects</p> Signup and view all the answers

    What concept in functional programming involves functions that operate on other functions?

    <p>Higher order functions</p> Signup and view all the answers

    According to the text, what is an important idea in functional programming related to the treatment of functions?

    <p>First-class treatment of functions</p> Signup and view all the answers

    What is a key characteristic of functional programming in relation to the use of functions?

    <p>Functions are only used for calculations</p> Signup and view all the answers

    Which of the following is NOT a characteristic of functional programming?

    <p>Modifying the state of the system</p> Signup and view all the answers

    What is a pure function in functional programming?

    <p>A function that calculates a result without any side effects</p> Signup and view all the answers

    What does a pure function in functional programming depend on?

    <p>Input parameters</p> Signup and view all the answers

    What is the primary characteristic of first-class functions in functional programming?

    <p>They can be stored in a variable, and passed as an argument to a function, or returned as the result of a function.</p> Signup and view all the answers

    What does immutability refer to in functional programming?

    <p>Objects that cannot be modified after they have been created</p> Signup and view all the answers

    Which of the following is an example of a pure function?

    <p>Finding the length of a string</p> Signup and view all the answers

    In functional programming, what does lazy evaluation emphasize?

    <p><code>Evaluation</code> only when the result is required</p> Signup and view all the answers

    Which of the following is NOT allowed in pure functions in functional programming?

    <p><code>Writing to a file or database</code></p> Signup and view all the answers

    What does recursion over loops emphasize in functional programming?

    <p><code>Recursion</code> as an alternative to traditional looping</p> Signup and view all the answers

    What is the purpose of higher-order functions in functional programming?

    <p>To pass functions as arguments or return them</p> Signup and view all the answers

    More Like This

    Use Quizgecko on...
    Browser
    Browser