QA's approach 2 Java - Elements of Java Programming

                              

                      Elements of Java Programming

There are basically 7 elements in Java programming:

 1. package (name should represent a group)

         {2. predefined & user defined class

          {3. variable(memory for storing variable)

           4. method (Logic to achieve working on the memory)

           5. constructor(Provides Memory &provides initial values, either default or custom defined)

           6. block(initialization logic common to all the constructors should be placed it inside block)

           7. inner class(used for creating an object inside another object) } }


Class can be created using 3 keywords

1.Class -> which has partial or full implementation
              variable
              methods
               {Variables}

2.interface --> type of class, which is just a abstract copy of what is to be implemented
              variable
              methods

3.enum --> type of class, used for listing of items or fixed constants of an object
              variable
              methods
               {Variables}

annotation -> type of interface, which provides description about the class [Metadata]
              variable
              methods

There are 6 types of class declarations:

abstract class
concrete class
final class
interface
annotations
enum

Analogy of package with directory structure

Folders->Files->Data
Package->Class->variables & methods


Class vs Object

Class (groups of similar objects)
Object ->contains variables & operations

Object -->instance of a class

Before writing a class, we need to arise at the question for which object we are developing the class
Java class for employee object
Oracle table for employee object

Object at 2 levels -

Declaration level--->using Interface
Implementation level --> using Class





Comments

Popular posts from this blog

QA's approach 2 Java - Understanding Static context

Selenium 4 absolute beginners - How to create Batch execution file

Technologies - Log4J - Create Log4j Configuration File - Where ? How ? What ?