Posts

Showing posts from March, 2021

Java OOP

               OOP sands for Object-Oriented Programming    Procedural Programming -: Writing procedures or methods that performs operations on data. Object-Oriented Programming -: Creating objects that contains both data & methods Advantages of object-oriented programming over procedural programming -: faster & easier to execute provide the clear structure for the programs keep DRY "Don't repeat yourself" principle, and makes the code easier to maintain, modify & debug. possible to create less reusable application with less code & shorter development time   Classes & Objects  Classes and objects are the two main aspects of object-oriented programming.  Look following examples to get idea about classes & objects -: ex 1-: class - fruit objects -: Apple, Banana, Mango ex2-: class-: Animal objects -: Dog, Cat, Monkey class is a template for object. object is an instance of a class. When the indiv...

Java Variables

 Variables are containers for storing data values. In Java, there are different types of variable. String - stores text. String values are surrounded by double quotes int - stores integers (whole numbers), without decimals float - stores floating point numbers, with decimals, such as 9.99 or -1.99 char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes boolean - stores values with two states(true or false)   Variable Declaration  Syntax -: type  name_of_variable = value;      type -:  String/ int/ float/ char/ boolean      name_of_variable -: such as x,x1,y      equal sign used to assign values to the variable.            ex -: String name= "mala"                    int age=24;                    float decnum=5.99f; ...