Skip to main content

Posts

Showing posts from July, 2023

Java program using abstract class and concrete class

 Java program using abstract class and concrete classes using Eclipse IDE Example program in abstract class and method package javaproject1; abstract class Abstract { abstract void display();  //method declaration only void show() { System. out .println( "This show method is normal method in abstract class" ); } } class AbstractDefinition extends Abstract { void display() { System. out .println( "This is display method definition" ); } } class AbstractDemo { public static void main(String args []) { AbstractDefinition obj = new AbstractDefinition(); obj .display(); obj .show(); } } Short explanation of  abstract class and concrete class

A java program for hierarchical inheritance

 A simple program for java  hierarchical inheritance  Java program using eclipse IDE package javaproject1; class Birds { void display1() { System. out .println( "Birds have wings and fethers" ); } } class Crow extends Birds { void display2() { System. out .println( "crow is a bird its color is black" ); } } class Parrot extends Birds { void display3() { System. out .println( "parrot is a bird its color is green" ); } } class HierachicalDemo { public static void main(String a []) { Crow crow = new Crow(); crow .display1(); Parrot parrot = new Parrot(); crow .display2(); parrot .display3(); parrot .display1(); } } Short explanation of hierarchical inheritance in java

Example program in java (oops) concepts

 Java programs for beginners in eclipse IDE Java single inheritance example program using  eclipse IDE package javaproject1; class Vehicle { double speed =80; void go() { System. out .println( "This vehicle is moving,Vehicle speed is :" + speed ); } void stop() { System. out .println( "This vehicle is stopped" ); } } class Car extends Vehicle { int wheel =4; int door =4; } class Inherits { public static void main(String a []) { Car car = new Car(); System. out .println( "Vehicle speed = " + car . speed ); car .go(); System. out .println( "This vehicle has :" + car . wheel + " wheel" ); } } Short explanation of single inheritance in java

Thread synchronization in java

 Java thread synchronization and types  what is synchronization how it work short explanation? synchronization is a technique through which we can control multiple thread execution at a time. If you apply the synchronization concepts on the thread instruction, automatically whatever the thread is executing the instruction, that thread will be in a lock procedure so that no other thread will interrupt this thread.All remaining thread will wait for until the running thread is completed. synchronization can be achieved in three way  Synchronized keyword —> Applied for method  As a prefix to the method in which statements written to be executed as a thread. synchronized block —> Applied for inside the method This should be applied inside the method,If we want to restrict this synchronization for a few lines in a method. Syntax synchronization(this){ Statements } synchronized static block ---> Applied for method Syntax Synchronization static return type method na...

java basic programs1

  simple java programs for beginners in eclipse IDE Data type example program in java using eclipse IDE package javaproject1; public class DataTypeExample { public static void main(String a []) { byte b_value =126; short s_value =32767; int i_value =221133; float f_value =3.14f; double d_value =4.888; char ch = 'a' ; boolean bln = true ; //true or false value only System. out .println( "java data type example program" ); System. out .println( b_value ); System. out .println( s_value ); System. out .println( i_value ); System. out .println( f_value ); System. out .println( d_value ); System. out .println( b_value ); System. out .println( ch ); System. out .println( bln ); System. out .println( "observe the output value carefully" ); } } short explanation of data type in java Different type variable declaration and printing program in eclipse IDE pa...

Java basic program using eclipse IDE

Example program in java multilevel Inheritance using eclipse IDE Multilevel inheritance program in java using eclipse IDE package javaproject1; class MultilevelInherit { public static void main(String[] args ) { Orange frt = new Orange(); frt .display2(); frt .display3(); frt .display1(); } } class Fruits{ int a_box =50; int o_box =25; void display1() { System. out .println( "Total orange box :" + o_box ); System. out .println( "Total apple box :" + a_box ); } } class Apple extends Fruits{ int kgm =40; void display2() { System. out .println( "This apple box is " + kgm + " kilogram" ); } } class Orange extends Apple { int kgm1 =20; void display3() { System. out .println( "This orange box is :" + kgm1 + " kilogram" ); } } short explanation of multilevel inheritance

Thread class methods in java

 Java thread class methods and its function  Thread class contains different methods, using these methods we can manipulate the thread. Some methods are given below. Thread class methos and its funtion start()---->A thread execution started from the start() method,unless you implement the start() method thread will not be started. run()----> implicitly called by the start() method sleep(milliseconds)---->suspends the thread for given milliseconds of time,This should be written in the try catch block as the exception occurs.This is a static method,So this method can be called directly. join()---->waits the thread to complete its process,used in multi threading,it should be written in the try catch block as the exception occurs.This is a static method,So this method can be called directly. getId()---->Gives the ID of the thread getName()---->Gives thread names,always start from thread-0 setName(sting)---->Thread name will be replace with given string getPrio...