Ask a question to Desklib · AI bot


Research on Object Oriented Language

Added on -2019-09-18

| 2 pages
| 647 words

Trusted by 2+ million users,
1000+ happy students everyday

Programming paradigmsLecture 14 Variables and scopesPass function to another function, what would be the scope of the function?Four types of scope: file scope, block scope, function prototype scope, and function scope. Block scope maybe nestedJava scope- Block scope and class and package scopeRuby scope- class definition, module definition, methods. We don’t declare a type in ruby because it is weakly typed.COMPARING SCOPES- MIGHT COME IN EXAMShadowing will cause problems because you don’t know which variable is running, something like that. RESEARCHObject oriented language should have three things: inheritance, encapsulation and polymorphismPolymorphism- inheritance is needed to have polymorphism. Static type should be the super type. Dynamic type is the sub type of the super 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 called dynamic binding. Lecture: Static typing and parsingNo information about type is attached to the variable or its value – Weak typingFunction/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 an instance 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 for each 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 the objects: student id, animals, furniture. As everything is an object in OO. This is dynamic typing therefore we have to check the list every time we run the code.ArrayList<Duck> list – only allows ducks in the list. Therefore we don’t have to check the list. Strongly typed. Static typing has type interface.REVISION

Found this document preview useful?

You are reading a preview
Upload your documents to download
Become a Desklib member to get accesss

Students who viewed this