Research on Object Oriented Language

Added on - 18 Sep 2019

  • 2


  • 647


  • 292


  • 0


Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 1 of 2 pages
Programming paradigmsLecture 14 Variables and scopesPass function to another function, what would be the scope of thefunction?Four types of scope: file scope, block scope, function prototype scope, andfunction scope. Block scope maybe nestedJava scope- Block scope and class and package scopeRuby scope- class definition, module definition, methods. We don’tdeclare a type in ruby because it is weakly typed.COMPARING SCOPES- MIGHT COME IN EXAMShadowing will cause problems because you don’t know whichvariable is running, something like that. RESEARCHObject oriented language should have three things: inheritance,encapsulation and polymorphismPolymorphism- inheritance is needed to have polymorphism. Statictype should be the super type. Dynamic type is the sub type of thesuper type. Ian gave an example of the shape hierarchy.Shape S= Circle (..). We cannot declare circle (..) =new shape SLook up polymorphism array slide. Polymorphism is also calleddynamic binding.Lecture: Static typing and parsingNo information about type is attached to the variable or its value – WeaktypingFunction/procedure overloading and Operating overloadingSame name, different signature- Function overloadingOverriding- inheritance hierarchyIn dynamic typing, variables do not have assigned types, but types do.Duck typing- dynamic typing in ruby. At runtime, a method is called on aninstance of an object. If the instance knows what to do with the method,then it does it. Otherwise you get an error message.In static typing, the compiler makes sure all values have right type foreach method.Generics are the way of telling a data structures. E.g. ArrayList list=newArrayList() – allows any object in the list in OO. Example of theobjects: student id, animals, furniture. As everything is an object in OO.This is dynamic typing therefore we have to check the list every time werun the code.ArrayList<Duck> list – only allows ducks in the list. Therefore we don’thave to check the list. Strongly typed.Static typing has type interface.REVISION
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document