Foundation For Object Generation , Data Types , Parameter & Arguments in OOP
Foundation For Object Oriented Programming(Java)
Object Generating In Java
First we want to know about what is an object in Java.
Object can be define as data field that has unique attributes and behaviors. Objects can correspond to real-world objects or an abstract entity.Why We Need Object In Java?
- It makes it possible to use the concepts of object-oriented programming (OOP). Code can thus be arranged into reusable parts, which facilitates code reusability, scalability, and maintenance.
How To Generate Object In Java?
- We can create any number of objects(no limit).
- Using "new" keyword, class reference and class constructor we can generate a new object.
Data Types
In computer programming, a data type is a classification that indicates the kind of value that may be stored in a variable or the type of data that can be returned by a specific expression. Programming languages are based on data types because they specify what kinds of data are available and what actions can be done with them.
There are several data types in java.
- Integer (int, byte, short, long): Represents whole numbers without any decimal point.
- Floating-point (float, double): Represents numbers with decimal points.
- Character (char): Represents a single character, such as a letter or a symbol.
- Boolean (boolean): Represents true or false values.
- String: Represents a sequence of characters (text).
- Array: Represents a collection of elements of the same data type.
- Class: Objects created from classes fall under non-primitive data types. Classes are user-defined data types that encapsulate data (attributes) and behaviors (methods).
- Interface: Interfaces in Java define a contract for classes to implement. Objects can be of the type of the interface.
Parameters and Arguments
Parameter
Parameters act as variables inside the method. Parameters are specified after the method name, inside the parentheses. You can add as many parameters as you want, just separate them with a comma.
Arguments
When a method is called, its actual values are sent in as arguments. The arguments used to invoke a method must be of the same type and order as the parameters in the declaration.
Comments
Post a Comment