Skip to main content

Posts

Showing posts from February, 2023

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...