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.
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.
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; ...
When we're coding, we will meet methods that we can't apply codes, So we can name them as Meaningless Methods . We can't store meaningless methods in an ordinary way. In that situation, We have to make Abstract methods using the keyword "Abstract". We can't store Abstract methods in an ordinary class. Therefore, we have to make the class also an abstract class using Abstract keyword. We can store abstract methods only in abstract classes. But we can store any method in an abstract class. The important thing is, we cannot create objects in an abstract class . Refer to the code sample given below, Abstract class Vehicle{ abstract void park (); } Abstract class Vehicle { Abstract void park (); void reverse (){ } } There is a code inside the meaningless method highlighted with Orange like , Ex :- class Vehicle { void park (){ } } The part highlighted in blue is a meaningless ...
Well done Hirun
ReplyDelete