Posts

Showing posts from March, 2023

Inheritance (OOP - JAVA)

Image
  Inheritance Let's consider the first BMW car and a BMW 740E car. There are lots of differences and similarities in   those cars.  See the similar properties for those cars, tires  engine light door  break liners seats steering wheel    See the similar behaviors for those cars, drive reverse break horn signal lights on/off See the newly properties for  BMW 740E, cameras sensors digital dashboard video player GPS air bags See the newly behaviors for  BMW 740E, auto pilot voice command When we think about the above properties and behaviors, we can see each an every property and behavior which is related to the first BMW car have been joined to the  BMW 740E car. In other words, the first BMW car properties and behaviors have been inherited to the  BMW 740E car. The things which are related to a class goes to another class is called Inheritance. We need to make a joint between two classes to do it. The first class is called as su...

Method Overloading (OOP - JAVA)

Image
  Method Overloading When we create same method continuously in a same class, we use method overloading concept. We can change the parameters, when we performing method overloading. We can say it method signature as well. Consider following code segment,     eg:   class World{                   void countries( int x ){                     }               void countries( String y ){                   }                }    Method signature segment has been painted in gray color.  Consider following code segment, void duneth () { } void duneth (String s) { } void duneth (int x) { } void duneth (int y, int z) { } duneth (3, 87) ; duneth () ; duneth ("Hello World") ; duneth (123) ; If you look ...

Parameters and Arguments, Constructors (OOP - JAVA)

Image
  Parameters and Arguments   Consider following code lines, A a = new A();   << this is the way to create a object as we know int b = 7;  << int is class of Integer class, b is a variable, 7 is the value String str = "duneth";       How to write the main method in java  public static void main(String[] args){ } Methods void myHeight( ){ } A method has a return type and a method name above example: return type - void , method name - myHeight consider following example, void addNumbers( ) {      int a = 2;      int b = 7;      int c = a+b;      System.out.print(c); } ( ) parameter is used for get the input and output values return type is used for return the output or input consider following example, void area(int x, int y){ } area(7,15);  (int x, int y) is a parameter list area(7,15) is a argument list When we add values to the argument list, it will transfer to the...

Object Creation, Data Types (OOP - JAVA)

Image
  OBJECT CREATION In java we can generate objects if only we have a class. We can convert only a class into object class Human{  } creating objects - Human h1 = new Human();                               Human h2 = new Human();                                      Human h3 = new Human(); eg: Human duneth = new Human(); class name of object - Human variable name - duneth object generate keyword - new class name of object with parameters - Human() semi colon -  ; if we consider a name with surname, surname : Anderson name : Michael                Stephanie               Jimmy in that case class is surname and particular object is name. 😇 we can write as below, 1st way         ...

Standards, Specific Operators, Class and Object (OOP - JAVA)

Image
OBJECT ORIENTED PROGRAMMING CONCEPTS IN JAVA Class Hierarchy 1.Object 2.Class 3.Method 4.Variable STANDARDS           We use some standards to write java codes 😇                   class Java {                       String str ;                       public void test() {                  }                  } We use simple letter to start variable names. We use camel case to write variable names.  (yellow) We use capital letters to start class names. We use mixed case to write class names. (purple) We use simple letters to start method names. We use camel case to write method names. (blue) eg: Duneth - class        duneth() - method       duneth - variable Java print statement...