Posts

Showing posts from October, 2022

Polymorphism

Image
      A concept that is made by the addition of Overriding, Inheritance, Casting is called Polymorphism.            Refer to this code sample,             class A {            void print (){            System.out.println ("A");            }             }             class B extends A{             void print (){            System.out.println ("B");            }            }            B b  = new B () ;            b.print();            A a = new A () ;            a.print () ;             ...

Up Casting & Down Casting (Casting concept)

Image
             There are 2 types of casting they are,                1. Up casting                                                                                                                                                                2. Down Casting       Up casting      Refer to the samples given below,      int x = 10;                 ...

Primitive Data Types

Image
            There are 8 Primitive data Types, byte -  Integers char - Integers   short - Integers int - Integers long - Integers float - Floating Point -- Decimal places double - Floating Point -- Decimal places Boolean - Binary -- 2 Options -- In java -- True or False       Refer the following,               int a = 5;       long b = 7;       a + b;       Is this statement true?       Yes its true, because both of them are in the type of Integers.           float c = 7.8;       double d = 5;       c + d;        Is this statement true?        Yes its true, because both of them are in the type of  Decimal points.        long e = 12345;        float c =  34.87; ...

Super Keyword

Image
      Refer to this code sample.        class Monkey {        Monkey(){        }        }        class Man extends Monkey{        Man(){         Super();        }        }       Super = Super class         The keyword super is used to call the constructor in the super class when you are in   the sub class. When we are using the super keyword in a constructor of the sub class, the constructor of super class will run in the constructor of the sub class. We can access methods and variables in the super class using the keyword super.

Method Overriding

Image
  Method Overriding Refer to this code sample.                                                   class Monkey {                       void eat (){                       // Eat with hands                        }                       void climb(){                       // Climb with the help of body                       }                       }                       class Man extends Monkey{     ...

Inheritance & Access Modifiers

Image
Inheritance Combining things of one property to another property is known as Inheritance. Consider these code samples, class Car (){                    class ModernCar{                          class Car{ void drive (){                  void drive (){                                void drive (){ }                                      }                                                    } void brake (){                 void brake (){              ...

Method Overloading, Static & Instance

Image
Method overloading                                                                                                               Jvm Compiler class hirun {                                                                                              compile programme;                                                       ...

Constructor, Parameter & Argument.

Image
                 Hello, Today I am going to explain what is a              Parameters & Arguments           Consider this code sample :           void car(){           }           void car ( int x ,  String y ) {           }           car ( 2, abn345 );          When considering this code sample, you can identify that,                Sea green ( highlight ) -- is Return Type                Red ( letters )-- are the 2 datatypes                Pink (highlight)-- is the PARAMETER               Orange (letters)-- are the ARGUMENTS   When we are ...

Class, Object & Creating an object

Image
 Hello I'm going to explain what is, and how to use  ,  A sample code on calling methods & giving  values to objects.                                                                                                                                                                                                                                                     ...

Class Structures, Variables, Methods & Class Names

Image
Class Structures T here are 2 class structures in Java namely, Class Structure & Main Class Structure. This is a chart that shows you the difference between a class Structure & a Main Class Structure.                 In the above figure these are the highlighted parts... Red- Variables Silver- Class name Blue- Method Yellow- Main Method   [in main class structure] When we are starting  class we're using open curly brackets-- { When we are starting a method we use closed curl bracket-- } We use a semicolon when ending a code line-- ; We're using parameters to store the data-- () Class Names Examples for class names-;  class  A xel                                                         class  A pple We can give any name to a class. We're using an up...

About Me

Image
 I am Hirun Yapa. I live in Maharagama. Actually I like ICT, I would like to post articles about Java and many more about ICT. Hope my articles will be useful to you all.