Class and object Flashcards
What is the highest level in the object model?
BasicObject
Is everything in Ruby an object?
Methods are not objects. Blocks are not objects. Keywords are not objects. However, there exist Method objects and Proc objects, and some keywords refer to objects.
Which core object includes the Kernel module?
Object
Is Ruby a statically typed or a dynamically typed language?
Dynamically typed since type checking is done at runtime.
Is Ruby a strongly typed or a weakly typed language?
Strongly typed since an object’s type is checked before an operation is performed on it.
what are the types of variables?
Local Variables
Instance Variables
Class Variables
Global Variables −
Differentiate - Class Variable and Instance Variable
A class variable is evaluated in reference to the class object created by the enclosing class definition while an instance variable is evaluated in reference to self. Instance variables cannot be referenced outside of instance methods.
Are class variables are inherited?
No. The behavior is different than inheritance. Any alteration of a class variable by a subclass affects that class variable in the superclass and all other subclasses of the superclass.
If a variable wihich has all upper case letter,that is called?
Constant
Why must a class name begin with a capital letter?
Because the class keyword creates a new constant that refers to the class and constants begin with a capital letter.