Object Oriented Programming - JAVA - Object Generation , Data types, Parameters & Arguments

Object Oriented Programming (JAVA) 👽

    There are many languages ​​that follow the OOP concept. They all are based on objects.  Java also a programming language that use the OOP concept. 
So we have to know,
  • Object generation
  • Method creation
  • Variable creation
  • Data types
  • Parameters & arguments

In this blog, we will discuss about object generation, data types and parameters & arguments.

Object Generation

    An object in the Java programming language is a replica of a certain class, which is known as an instance of a Java class.  A class object's actions and attributes are its fundamental components.



When we create an object , we have to follow a structure.  It has 4 characteristics. 
  • class reference
  • variable name
  • 'new' keyword
  • class constructor


Data Types

Data types specify the different sizes and values that can be stored in the variable.
There are two types of data types in java
  • Primitive data types
  • Non primitive data types


Each primitive data types has variable size, value range and default value. 


Parameters and Arguments

Parameters.....

Parameters refers to the list of variables in a method declaration. That values are use to operations within methods. 
    Method must include a return type. The data types of all parameters are the same as the method return type. "void" is the default return type. We assign values ​​to the method's parameters using method calls outside the method.

                   double math( double y ){
                        return y;
                   }
                   math (6.5428);


Arguments.....

    Arguments are the actual values ​​that are passed in when the method is invoked. 
Give your attention for below method and arguments.


                   void method( int x, String y ){
                        return y;
                   }
                   
 In this case we can only give integer value for x and string value for y. 
Let's look at some examples with our reasoning as to what is suitable for this method.

(1)  method (12, 154);                            because of y value is not in string type
(2)  method ( 12.5, "Java");                    because of x value is not integer value
(3)  method (12, '#');                               because of y value is character
(4)  method (12 , "Java");                

Let's meet in the next blog to discuss about java class, variables, modifiers and methods & main method.



Comments

Popular posts from this blog

Sorting Algorithms - JAVA👽

Object Oriented Programming - JAVA- class boundary, variable types, modifiers, java main method

Object Oriented Programming - JAVA- Method Overriding