Skip to main content

Posts

Abstraction In Java Programming Short Explanation

 ABSTRACT CLASS AND ABSTRACT  METHOD IN JAVA  What is abstraction in java? Showing only  essential parts and  hiding the implementation part. This is called abstraction.This can be achieved by  java programming. Ex:-- while download  android application in playstore we get only .exe file.when running this exe file the software will work but we cannot see the implementation part.This type of application can be done by java programming,this technique is called abstraction or data hiding Abstract class and abstract method abstract class and abstract method in java with example We know that abstraction is a pillar of the oops concepts,and abstraction is showing only essential parts and hiding implementation details.The class contains variables, methods and constructors.So if any class consists of at least one abstract method then the class will be called an abstract class. The abstract class and abstract method is created using the abstract keyword.An ab...

Hierarchical Inheritance In Java with Example Program

  Hierarchical Inheritance In Java with Example Program Hierarchical Inheritance Inheritance which contain only one parent class and multiple child class, and all child class directly extends the parent class this is called hierarchical inheritance For example, consider A, B and C as three classes: A parent class,B and C are two child classes.Here B & C extends to A class,Similarly object should be created separately for B & C class.So B&A class property can be accessed using B class object. C&A class property can be accessed using C class object. Hierarchical Inheritance in java example program Program class Parent { int age1=50; void display1() { System.out.println("This is parent class method disply1"); System.out.println("Parent class accessing through both obj1 and obj2"); System.out.println("____________________________________"); } } class Bchild extends Parent { int age2=40; void display2() { System.out.print...

Multilevel Inheritance In Java with Example program

  Multilevel  Inheritance In Java With Example Programs Multilevel Inheritance In single inheritance we have only one parent class and one child class but multilevel inheritance the child class again have subclasses.This technique is called multilevel inheritance For example, if A, B and C are three classes, we can inherit class B to class A and class C to class B using extends keyword. Also, if we create a C class object, we can access the properties of all three classes. We can limit the object creation in inheritance. This is the advantage of inheritance. Java multilevel inheritance example program class A { int age1=50; void display1() { System.out.println("This is parent class method disply1"); System.out.println("parent class also known as base class"); System.out.println("Another name super class "); } } class B extends A { int age2=40; void display2() { System.out.println("This is child class method disply2"); Sy...

How to run java simple program using notepad

 Java simple program using notepade and cmd-Based on java basic notes 1  Java hello world program class Hello1{ public static void main(String arg[]){        System.out.println("Hello World");     }       } 2 Java program to create a string variable class StringExample {   public static void main(String[] args)  {     String line1 = "Hello world"; String line2 = "welcome to java programming";     System.out.println(line1+'\n'+line2);   } } 3 Java program to print both small and capital alphabets class Alphabets {       public static void main(String args[]){             char ch;             System.out.println("Small Alphabets: "); System.out.println("----------------");             for( ch = 'a' ; ch <= 'z' ; ch++ ){                System.out.p...

Inheritance-Java oops concepts-Single Inheritance

single inheritance in java with example programs  Inheritance Inheritance means one class acquiring the properties of another class this can be also called as parent child, that means child class acquire the properties(accessing variables and methods) of parent class. Parent class also known as super class(or base class) and child class known as sub class(or derived class) Implementing inheritance concept we will use the extends keyword Single inheritance  single inheritance in java program with output Single inheritance means only one base class and one derived class. Java single inheritance Sample program single inheritance in java example program   class Main1 { public static void main(String args[]) { ChildExample obj=new ChildExample(); obj.display(); System.out.println("Age is :"+obj.age); obj.display1(); System.out.println("Age is :"+obj.age1); } }   class ParentExample { int age=60; void display() {   Sys...

static keyword in java short explanation

  Static variable-static method and static block static keyword  The static keyword in Java is mainly used for memory management. When a member is declared static, it can be accessed directly.To create a static member, the static keyword is used before its declaration.Block, variable, method and classes can use static keyword. java buzzwords explanation static variable and static method in java have different types of variables are available local,instance and static variable In a class global variables are declared using the static keyword Definition of object —>An object is programming entity and class is collection of object Every class will be having variables and methods If the variable declare as a static these static variable can be access into two ways 1 directly access—>If our program is in a single class You can directly access the variable 2 with the help of class name—->If your program is in multiple classes You can access the variable with the help of cla...

Java variable program using notepad CMD output

 Java  variable program using notepad CMD output Different type variabe diclaration and printing program class Variable{ static  int age=25;  //static variable int ID=498;  // instance variable  public static void main(String args[]){ String name="Habiba";    // local variable System.out.println(name);  // Habiba printed System.out.println(age);    // 25 printed Variable object1=new Variable(); // object creation System.out.println(object1.ID);  // 498printed } }

Java short note in constructor-Java programming

Constructor in java short note with example program constructor constructor is a method with the same name as the class name that is generally used to Initialize the instance variable and does not return any value, not even void. Before understanding what is constructor , let's see how object is created Syntax of object creation Classname objectname=new constructor(); here new  is java keyword  used to create an object (instance) constructor are called automatically when a new object is created when an object is created in java using the keyword new following things happen: Memory is allocated for new objects Instance variables of the objects are initialized, either to their initial values or to default values(0 for number,null for objects) A constructor is invoked Constructor() is used to initialize the object Rules to be followed creation of constructor constructor name must be equal to class names constructor does not have return type It is  entirely different from a...