+ 6
Why are C++ and Java called Object oriented programmng languages?
Please explain in easy language with syntax or codes as examples. Thank you
3 ответов
+ 4
So that simply means that all objects inside a function are being called whenever they are to be used ?
+ 2
Its possible to force the concept of object oriented programming into almost any language but there is a difference between a programming language that allows for OOP (Object oriented programming) and one that expands upon the concept. In a short summary, think of any store as a program. The company name would be the program name, and you could have class files for (objects) for things like merchandise, the register, backroom, etc. For instance buying something would call the registers method register.transaction() and would look something like this onsode the program:
public double transaction(int cashTendered, Merchandise m){
double price = m.getprice(); //this gets the price of the m object
+ 1
more or less, you need to use a constructor to call instances of an object. somwthing like
ClassName(){
<optional variable declarations and statements>
}
and would call the constructor by doing
ClassName variableName = new ClassName();
other wise for static classes (ones you can't create an instance of) you can just reference ita variables by doing ClassName.variableName