Posts

Encapsulation

Encapsulation is the process of wrapping or binding all the functions and data together into a single unit. So we can hide the implementation of the code from the user by using access specifiers. We can make private member variables and have public getters to read data from the variable and setters to write data to the variable, so likewise we can control the access to those variables. Code: public class TestEncapsulation{ public static void main(String args[]){ Circle c1=new Circle(7.0); System.out.println("Radius of the circle is:"+c1.getRadius()); System.out.println("Perimeter of the circle is:"+c1.getPerimeter()); c1.setRadius(14.0); System.out.println("Radius of the circle is:"+c1.getRadius()); System.out.println("Perimeter of the circle is:"+c1.getPerimeter()); } } class Circle{ private double radius; private double perimeter; Circle(double radius){ this.radius=radius; setPerimeter(); } public void setRadiu...

Abstraction

Showing only the functionalities in more generalized manner is called as abstraction. In java we can achieved this either by implementing an Interface or an abstract class. Interface provides 100% abstraction while Abstract class can provide a partial abstraction in between 0% to 100%. Abstract Class If a class is declared using the key word "abstract" then we called it as an abstract class. We can't instantiated an abstract class. (Can't make objects) but it can have sub classes. Code: -------------------------------------------------------------------------------------------------------------------------------- public class TestAbstractClass{ public static void main(String args[]){ Student s1= new Student("John", 18); s1.eat(); s1.sleep(); } } -------------------------------------------------------------------------------------------------------------------------------- abstract class Person{ String name; int age; Person(Strin...

පුන් සඳ ඔබයි රන් තැලියෙන් කිරි බෙදන

Image
ලෝදිය කුස දරා මිහි මඩළ ලොවට ම ජීවන සුසුමන් පොවන කළ අම්මාවරුන් බඳු යැයි කවියො කිව හළ ඔබට ම ගැළපේය යැයි සිතුනි මේ කළ හදවත වේදනාවෙන් මිරිකී හඬන විට අම්මේ නුඹේ ළමැඳ මුව හොවා ගත් විට දුරු වෙයි සියලු දුක් කරදර ගැහැට අම්මේ ඔබටවන් හදක් නොමැත මිහිපිට හිරු දෙවියන් අවර දිගින් ගිය විට පැන හඳ තරු අහස් ගැබෙන් ඉස්මතු වන ජීවිතය අමාවකයක් ම වූ දින පුන් සඳ ඔබයි රන් තැලියෙන් කිරි    බෙදන

ඒ යුගයේ සෙවණැලි ද මේ හොල්මන් කරන්නේ..

Image
මහා සයුර කළු කරනා අහස් කුස ගිගුම් දෙනා නිරයෙන් ගෙන ආ ලෝදිය කඳු තුඩු නගනා ඍතුවකි ඇරඹුනේ.. ආයුධ වැසි වසිනා රාගය පිටාර ගලනා චණ්ඩ මාරුතය කි මිනිස්කම ගිලගන්නා මේලොව විශ්ව කතරේ සොහොනක් වන්නේ.. බුදුනුත් කීවා එදා පණ්ඩිතුමොත් කීවා එදා ආලෝකය ඩැහැගන්නා අඳුරු යුගයක් එනවා කියා ඒ යුගයේ සෙවණැලි ද මේ හොල්මන් කරන්නේ..

පොසොන් සඳ

මහ සම්මත මනු රජුගේ සිට                    එකළ මහබලි, රාවණ, දෙවිඳු රජ                        කළ දිය, ගොඩ, අඹර අනුහස් දිය                   පතළ යක්, නා, රකුස්, අසුරන් පසින්දු සිව්           හෙළ මැණික් ඔබා තිබු ඒ සිහසුන                  රන්මය බුදුන් වැඩි දා දාගැබ් කළෙ             හෙළයන්මය එකළ ද ඔව්න් අසනට මේ අමයුරු           ධර්මය බුද්ධිකය සිරිකත මේ පින්                     බරමය තෙවරක් ගෞතම බුදු ඕභස් ලැබු මේ            රට වඩිති බුදුන් කැල මේ කප මහ           මෙව්නාවට මෙවන් උතුම් සිරිබර...

Flow Charts

Image
What is a problem? Problem solving techniques Algorithm Flowcharts Flow chart symbols/notations Basic symbols Line symbols Special symbols Data symbols Process symbols Flow control structures Sequences Selections If If/else Switch/ case Iteration While loop Do while loop Repeat Until For next loop Questions and Answers References What is a problem?                   A problem is an obstacle, impediment, difficulty or challenge, or any situation that invites resolution; the resolution of which is recognized as a solution or contribution toward a known purpose or goal. Problem Solving Techniques There are many problem solving techniques we can use to solve problems. Some are shown below... Structured approach Top down approach Brute force approach Divide and conquer approach Algorithm is an example for the structured approach   problem solving method….   What is Algorithm?...