Color example using Applet

import java.awt.*; import java.applet.*; public class Color1 extends Applet {   public void paint (Graphics g)   {     Color Pigment;     int Red;     int Green;     int Blue;    ...
READ MORE - Color example using Applet

Program to demonstrate - toString()

class CD { String title;           // name of the item int length;             // number of minutes boolean avail;         ...
READ MORE - Program to demonstrate - toString()

Program to demonstrate inheritance (Example-2)

class Car {     public String make;     protected int weight;     private String color;     private Car(String make,int weight,String color)     {        ...
READ MORE - Program to demonstrate inheritance (Example-2)

Program to demonstrate super() in java

class CD { String title;           // name of the item int length;             // number of minutes boolean avail;         ...
READ MORE - Program to demonstrate super() in java

Program to demonstrate super() in java

class CD { String title;           // name of the item int length;             // number of minutes boolean avail;         ...
READ MORE - Program to demonstrate super() in java

Program to demonstrate static variables, methods in java

class UseStaticMember {     //static variable static int x=4; //static method static void display() {     System.out.println("x : "+x); } } class StaticmemDemo2 { public static void main(String args[]) { System.out.println("x...
READ MORE - Program to demonstrate static variables, methods in java

Program to demonstrate static variables in java

class StaticDemo1 { static int x=4; static int y; static void display(int a) { System.out.println("x : "+x); System.out.println("y : "+y); System.out.println("a : "+a); } static { System.out.println("Static block====="); y=x*x; } public static void...
READ MORE - Program to demonstrate static variables in java

Program to demonstrate Single inheritance

//Single inheritance //create a superclass class A {     int a1;            //public by default     protected int a2;   //protected to A    ...
READ MORE - Program to demonstrate Single inheritance

Program to demonstrate inheritance

//Simple example of inheritance //create a superclass class A {     private int a;     void showa()     {         System.out.println("a : "+a);     } } //create...
READ MORE - Program to demonstrate inheritance

Program to demonstrate movie database using Method overriding(Example-2))

//Method overriding class CD { String title;           // name of the item int length;             // number of minutes boolean avail;         ...
READ MORE - Program to demonstrate movie database using Method overriding(Example-2))

Program to demonstrate movie database using Method overriding

 Program to demonstrate movie database using Method overriding //Method overriding class CD { String title;           // name of the item int length;            ...
READ MORE - Program to demonstrate movie database using Method overriding

Program to demonstrate movie database

 Program to demonstrate movie database class CD { private String title;           // name of the item private int length;            ...
READ MORE - Program to demonstrate movie database

Program to find which day of week today using Interface

Program to find which day of week today  using Interface   interface Week { int Monday=1; int Tuesday=2; int Wednesday=3; int Thursday=4; int Friday=5; int Saturday=6; int Sunday=7; } class Day implements Week { void display(int day) { switch(day) { case...
READ MORE - Program to find which day of week today using Interface

Program to find which day of week today using Interface

Program to find which day of week today  using Interface   interface Week { int Monday=1; int Tuesday=2; int Wednesday=3; int Thursday=4; int Friday=5; int Saturday=6; int Sunday=7; } class Day implements Week { void display(int day) { switch(day) { case...
READ MORE - Program to find which day of week today using Interface

Program to find area of rectangle and circle using Interface

Program to find area of rectangle and circle using Interface interface Area  //interface defined {     float pi=3.14F;     float compute(float x, float y); } class Rectangle implements Area { public float compute...
READ MORE - Program to find area of rectangle and circle using Interface

Program to find area of rectangle using Interface

Program to find area of rectangle  using Interface interface Area  //interface defined {     float pi=3.14F;     float compute(float x, float y); } class Rectangle implements Area { public float compute (float...
READ MORE - Program to find area of rectangle using Interface

Program to demonstrate Students Marks using Interface

class student {     int roll_number;         void get_number(int a)         {                 roll_number = a;        ...
READ MORE - Program to demonstrate Students Marks using Interface

Program to demonstrate Interface in Java

Program to demonstrate Interface in Java interface NewShape {     void draw(); } interface Circle extends NewShape {     void getRadius();     int radious=10; } class NewCircle implements Circle {    ...
READ MORE - Program to demonstrate Interface in Java

Program to demonstrate Employee Informatiom by passing parameters in constructors of different class

Program to demonstrate Employee Informatiom by passing parameters in constructors of different class class staff {     private int code;     private String name;     private String address;    ...
READ MORE - Program to demonstrate Employee Informatiom by passing parameters in constructors of different class

Program to demonstrate Dynamic method dispatch

 Program to demonstrate Dynamic method dispatch  //Dynamic method dispatch class CD { void message() { System.out.println("Inside CD's method"); } } class Movie extends CD { //override message void message() { System.out.println("Inside...
READ MORE - Program to demonstrate Dynamic method dispatch

Program to demonstrate Constructors

class CD { CD() { System.out.println("Inside CD's constructor"); } } class Movie extends CD { Movie() { System.out.println("Inside Movie's constructor"); } } class DocumentoryFilm extends Movie { DocumentoryFilm() { System.out.println("Inside DocumentoryFilm's...
READ MORE - Program to demonstrate Constructors

Program to demonstrate Company Record of Person

Program to demonstrate Company Record of Person //super class class Person {     protected String name;     protected int code;     Person(String n,int c)     {        ...
READ MORE - Program to demonstrate Company Record of Person

Program to demonstrate CD store

Program to demonstrate CD store class CD { String title; int length; boolean avail; CD(CD vt) { title=vt.title; length=vt.length; avail=vt.avail; } CD(String t, int l,boolean a) { title=t; length=l; avail=a; } CD() { title=null; length=0; avail=false; } } class...
READ MORE - Program to demonstrate CD store

Program to demonstrate Bank Account using Abstract class and Abstract method

Program to demonstrate  Bank Account using Abstract class and Abstract method abstract class Account {         protected int number;         protected String name;    ...
READ MORE - Program to demonstrate Bank Account using Abstract class and Abstract method

Program to demonstrate Abstract class and Abstract method

 Program to demonstrate Abstract class and Abstract method abstract class Shape {     protected double bs,ht,area;     void getdata(double b, double h)     {     bs=b;    ...
READ MORE - Program to demonstrate Abstract class and Abstract method

Program to demonstrate System.out.write()

/* Program to demonstrate System.out.write() */ class WriteDemo {     public static void main(String args[ ])     {         int i; char c ; float f;double d;        ...
READ MORE - Program to demonstrate System.out.write()

Program to read a string and rewrite it in alphabetical order

/* Program to read a string and rewrite it in alphabetical order  */ import java.io.DataInputStream;     // to load DataInputStream class         class P27 {     public...
READ MORE - Program to read a string and rewrite it in alphabetical order

Program to demonstrates the charAt( )

/* Program to demonstrates the - charAt( ) */ class charAtDemo {     public static void main(String args[ ])     {         String s = "INDIA";         char ch;    ...
READ MORE - Program to demonstrates the charAt( )

MCQ's on Java Fundamentals

1. Which is a valid keyword in java? A. interface B. Float C. string D. unsigned Click for answer  A. interface 2. Which is a reserved word in the Java programming language? A. method B. array C. native D. reference D. subclasses Click...
READ MORE - MCQ's on Java Fundamentals

Program to illustrate reading data from keyboard

 Program to illustrate reading data from keyboard import java.io.DataInputStream;      // load class for reading purpose class StringtoNumber {     public static void main(String args[])    ...
READ MORE - Program to illustrate reading data from keyboard

Program to demonstrate static variables, methods, and blocks

/* Program to demonstrate static variables, methods, and blocks */ class StaticDemo1 {     static int a = 5;     static int b;     static void display(int c)     {        ...
READ MORE - Program to demonstrate static variables, methods, and blocks

Program to Demonstrates- Returning an Object

/* Program to Demonstrates- Returning an Object */ class Rational {     int numerator;     int denominator;     Rational(int a, int b)     {         numerator...
READ MORE - Program to Demonstrates- Returning an Object

Program to demonsrates Recursion - Factorial of a given number

/* Program to demonsrates Recursion - Factorial of a given number */ class Factorial {     int fact(int n)     {         int result;         if(n==1)    ...
READ MORE - Program to demonsrates Recursion - Factorial of a given number

Program to demonstrate Using Object as Parameters

/* Program to demonstrate ‘Using Object as Parameters’ */ class Rectangle {     int length;     int width;     // Construct clone of an object     Rectangle(Rectangle obj)    ...
READ MORE - Program to demonstrate Using Object as Parameters

Program to demonstrate 'this' keyword

/* Program to demonstrate  'this' keyword */ class Rectangle {     int length;     int width;     //  use 'this' to resolve name-space collisions.     Rectangle(int length ,int width)    ...
READ MORE - Program to demonstrate 'this' keyword

Program to demonstrate Constructor overloading

/* Program to demonstrate  Constructor overloading */ class Rectangle {     int length;     int width;     //  Constructor used when all values are specified     Rectangle(int l,int...
READ MORE - Program to demonstrate Constructor overloading

Program to demonstrate parametrized Constructor

/* Program to demonstrate parametrized Constructor */ class Rectangle {     int length;     int width;     // This is parameterized Constructor for Rectangle     Rectangle(int l,int w)    ...
READ MORE - Program to demonstrate parametrized Constructor

Program to demonstrate Constructor

/* Program to demonstrate Constructor */ class Rectangle {     int length;     int width;     // This is Constructor for Rectangle     Rectangle()     {        ...
READ MORE - Program to demonstrate Constructor

Program to demonstrate method that takes parameters

/* Program to demonstrate method that takes parameters */ class Rectangle {     int length;     int width;     // compute and return Area of a Rectangle     int area()     {    ...
READ MORE - Program to demonstrate method that takes parameters

Program to demonstrate Method returning a value

/* Program to demonstrate returning a value */ class Rectangle {     int length;     int width;     // compute and return Area of a Rectangle     int area()     {    ...
READ MORE - Program to demonstrate Method returning a value

Program to demonstrate method

/* Program to demonstrate method */ class Rectangle {     int length;     int width;     // display Area of a Rectangle     void area()     {        ...
READ MORE - Program to demonstrate method

Program to demonstrate the use of other class

/* Program to demonstrate the use of  other class.    Call this file RectangleDemo1.java */ class Rectangle {     int length;     int width; } // This class declares an object of type Rectangle. class RectangleDemo1 {    ...
READ MORE - Program to demonstrate the use of other class

Program to compute value of x1 and x2 of linear equations

 Program to compute value of x1 and x2 of linear equations import java.io.DataInputStream;     // to load DataInputStream class         class LinearEq {     public static...
READ MORE - Program to compute value of x1 and x2 of linear equations

Program to represent Bank Account- Using Constructor

 Program to represent Bank Account- Using Constructor import java.io.DataInputStream;   // to load DataInputStream class class Bank {     String name,type;     int acno,bal,wit,dep;    ...
READ MORE - Program to represent Bank Account- Using Constructor

Program to represent Bank Account

 Program to represent Bank Account import java.io.DataInputStream;   // to load DataInputStream class class Bank {     String name,type;     int acno,bal,wit,dep;     // To assign initial...
READ MORE - Program to represent Bank Account

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|