CMSC 330 Final(100% Correct answers)
Turing Complete correct answers • A language is Turing complete if it can compute any function computable by a Turing Machine Syntax correct answers • What a program looks like Semantics correct answers • What a program means Attributes of a Good Language correct answers • Naturalness • Security & safety • Cost of Use • Portability Ruby Intro correct answers • Ruby is an object-oriented, imperative scripting language Explicit vs Implicit Declarations correct answers • Java and C/C++ use explicit variable declarations - Variables are named and typed before they are used • In Ruby, variables are implicitly declared - First use of a variable declares it and determines type Method Return Values correct answers • Value of the return is the value of the last executed statement in the method Style correct answers • Names of methods that return a boolean should end in ? • Names of methods that modify an object's state should end in ! • All Ruby conditional statements must be terminated with the end keyword What is True? correct answers • The true branch is taken if the guard evaluates to anything except: false, nil • Warning to C programmers: 0 is not false! Classes and Objects correct answers • Class names begin with an uppercase letter The new method creates an object • s = S creates a new String and makes s refer to it • Every class inherits from Object Everything is an Object correct answers • Everything is an object in Ruby Standard Library Arrays correct answers Arrays of objects are instances of class Array • Arrays may be heterogeneous a = [1, "foo", 2.14] • C-like syntax for accessing elements, indexed from 0 x = a[0]; a[1] = 37 Standard Library Hash correct answers • A hash acts like an associative array italy["population"] =
Document information
- Uploaded on
- May 28, 2024
- Number of pages
- 20
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers