Ad

Wednesday, September 20, 2017

Coding Interview Questions - OOP

Class definition



class Person(object): 
 def __init__(self, name, age): 
      self.name = name 
      self.age = age 
 def birthday(self): 
      self.age += 1

Note class name is capitalized. Initialization is the constructors where self.xyz defines class variables. Next def defines a function. Class functions take self as the default, 1st parameter.

No comments:

Post a Comment

Error Message Hardhat debugging error unsupported engine hardhat, current node v18

Error message npm WARN EBADENGINE  Unsupported engine { package: 'hardhat@2.9.3', required: { node: '^12.0.0 || 14.0.0 || 16.0.0...