Java Tutorials

Java Program For Abstract Class and Abstract Method 0

Java Program For Abstract Class and Abstract Method

Program 1 /* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ package abstractpack; abstract class MyButton { abstract void click(); abstract void dbclick(); } Program 2 /*...

Java Program For Access Specifier in Package 0

Java Program For Access Specifier in Package

Program 1 package pack1; public class First { private int a_pri=100; protected int a_pro=200; public int a_pub=300; int a_def=400; } Program 2 package pack1; public class Second { public static void main(String[] args) {...

Java Program For Has-A Relation 0

Java Program For Has-A Relation

Program 1 package emp; public class EmpInfo { PersonalInfo P; int empid; String DeptName; int Salary; public EmpInfo(PersonalInfo P, int empid, String DeptName, int Salary) { this.P = P; this.empid = empid; this.DeptName =...

Java Program For this Keyword 0

Java Program For this Keyword

Program 1 package testcoreproject; class Employee { //Instance variable private int id; private String name; private String dept; Employee(int id,String name,String dept) // Local variable { this.id=id; this.name=name; this.dept=dept; } void display() { System.out.println(“ID...

Java Program For Static Keyword Execution 0

Java Program For Static Keyword Execution

Program 1 //static variable package testcoreproject; public class Abc { static int count=0; Abc() { count++; } void display() { System.out.println(“Total Object Created: “+count); } } Program 2 package testcoreproject; public class Abc1 {...

Java Program For final Keyword 0

Java Program For final Keyword

Program 1 package testcoreproject; import java.awt.*; class Base1 { public static final float PI=3.14f; int factorial(int n) { int f=1; while(n!=0) { f=f*n; n–; } return f; } } class Derived1 extends Base1 {...

Java Program For super and this Keyword 0

Java Program For super and this Keyword

Program 1 package testcoreproject; class Student { int rno; String name; int per; Student(int rno,String name,int per) { this.rno=rno; this.name=name; this.per=per; } } class First1 { int m=100; // super class data void display()...

Java Program For super Keyword 0

Java Program For super Keyword

Program 1 package testcoreproject; class First { int a,b; First(int x,int y) { System.out.println(“Constructor of Class first with 2 parameter”); a=x; b=y; } First(int x,int y,int z) { System.out.println(“Constructor of Class first with 3...