Java Programs

March 29, 2017 | Author: kvp794 | Category: N/A
Share Embed Donate


Short Description

Download Java Programs...

Description

LIST OF JAVA PROGRAMS:S.No 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

Programs Program to Demonstrate simple JAVA program Program to compute the area of a circle Program to demonstrate type casting in JAVA Program to demonstrate the basic Arithmetic Operations Program to find largest of three numbers Program to print first 10 Fibonacci numbers Program to Calculate the factorial of a number using RECURSION Program to print prime numbers using CLA Program to Demonstrate Command Line Argument Program to convert temperature from Fahrenheit to Celsius using CLA Program to produce conversion table dollar and rupees using CLA Program to print area of right angled triangle using CLA Program to print all the elements in an array using CLA Program to find the sum of all the elements in an array Program to print all the elements in a 2D array Program to find the sum of two matrices Program to find the difference of two matrices using CLA Program to print the UPPER and LOWER triangle of a matrix Program to find the trace of a matrix Program to find the transpose of a matrix Program to find the product of two matrices Program to demonstrate a CLASS Program to demonstrate a Constructor Program to demonstrate a Parameterized Constructor Program to Demonstrate THIS keyword Program to Demonstrate Constructor Overloading Program to pass objects as parameters Program to Demonstrate Queue using Class Program to Demonstrate Stack using Class Program to Demonstrate Access Specifiers Program to Demonstrate Static Variables Program to Demonstrate Static Methods Program to demonstrate an Inner class Program to Demonstrate Type Wrapping Program to Demonstrate Single Inheritance Program to Demonstrate Multilevel Inheritance Program to Demonstrate hierarchical Inheritance Program to show SUPER Class variable to refer a sub class object Program to Demonstrate Method Overriding Program to Demonstrate Runtime Polymorphism Program to Demonstrate Abstract Class

© www.udaysatya.blogspot.com

PgNo. 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 31 32 34 36 37 38 39 40 41 43 45 47 48 49 51 Page 1

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

Program to Demonstrate FINAL Keyword Program to Demonstrate FINAL Method Program to Demonstrate FINAL Class Program to Demonstrate INTERFACE Program to access implementation through Interface references Program to Demonstrate EXTENDING INTERFACE Program to Demonstrate Stack using interface Program to Demonstrate Queue using Interface Program to Demonstrate a SIMPLE PACKAGE Program to Demonstrate Exception Program to Demonstrate TRY CATCH Program to Demonstrate CATCH ARITHMETIC Exceptions Program to Demonstrate Multiple CATCH Program to Demonstrate NESTED TRY Program to Demonstrate FINALLY clause Program to Demonstrate User Defined EXCEPTIONS Program to Demonstrate Throws Program to Demonstrate MULTITHREADING Program to Demonstrate Runnable Interface Program to Demonstrate Thread Priorities Program to Demonstrate Synchronized Block Program to Demonstrate Synchronized Method Program to Demonstrate Deadlock Program to Demonstrate Thread Methods Program to Create Threads using Thread Class Program to Demonstrate Join() & isAlive() methods Program to Show how to Get User Input from Keyboard Program to Create a Frame Window using Applet Program to Demonstrate Life cycle of methods in Applet Program to display Parameters Passed from HTML Program to Demonstrate all shapes in Graphics class Program to Show a Hut,Mountains & Face Program to Show Status of Applet Window Program to Show Position of the Mouse Program to Demonstrate Colors Program to Pass Parameters perform Mathematical Operations Program To Get Document Code Bases Program to Show an Image

Program to demonstrate an Adapter Program to Demonstrate Simple Banner Program to Demonstrate Button Program to Demonstrate Checkbox Program to Demonstrate Radio Buttons (Checkbox Group) Program to Demonstrate Choice

© www.udaysatya.blogspot.com

52 53 54 55 56 58 59 61 63 64 65 66 67 68 69 70 71 72 74 76 78 80 82 84 86 88 90 91 93 94 96 97 99 100 102 103 104 105 106 108 110 112 114 116 Page 2

86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116

Program to Demonstrate File Dialog Program to Demonstrate Labels Program to Demonstrate Lists Program to Demonstrate Menu Program to Demonstrate Text Area Program to Make a Login Window Program to Make a Login Focus Program to Demonstrate Mouse Adapter Program to Demonstrate Mouse Events Program to Demonstrate the key event handlers Program to Demonstrate Border Layout Program to Demonstrate Card Layout

Program to Test Fonts Using Mouse Events Program to Demonstrate Grid Layout Program to Demonstrate Scrollbar

Program to Check Connection to Database Program to retrieve Records from Database Program to demonstrate Insertion into Database Program to demonstrate Update into Database Program to demonstrate Prepared Statement Program to Demonstrate Data Entry using Applet Program to Demonstrate Result Set Meta Data Program to Demonstrate Transaction handling Program to Demonstrate Callable Statement Program to Demonstrate Result Set Meta Data Program to Demonstrate Database Meta Data Program to add Interface Program to add Server Program to add Client Program for implementation for the interface Create a Policy to Allow Permission for Everyone

© www.udaysatya.blogspot.com

117 121 122 124 128 129 131 133 134 136 138 139 141 143 144 146 147 148 149 150 151 154 155 156 157 158 159 159 160 161 161

Page 3

01 Program to Demonstrate simple JAVA program class A { public static void main(String args[]) { System.out.println("Welcome to my World"); } } ----------------------------------------------------------------------------------------Save the above Program as A.java Compile Program in Command by using javac C:\>javac A.java Run the Program in Command by using java C:\>java A --------------------------------------------------------------------------------------------OUTPUT : Welcome to my World

© www.udaysatya.blogspot.com

Page 4

02 Program to compute the area of a circle class A2 { public static void main(String args[]) { int r=10; System.out.println("Radius of Circle :" + r); System.out.println("Area of Circle :" + r*r); } } OUTPUT : Radius of Circle : 10 Area of Circle : 314

© www.udaysatya.blogspot.com

Page 5

03 Program to demonstrate type casting in JAVA class conversion { public static void main(String args[]) { byte b; int i=257; double d=323.142; System.out.println("\nConversion of int to byte."); b=(byte) i; System.out.println("i and b " +i+" "+b); System.out.println("\nConversion of double to int."); i=(int)d; System.out.println("d and i " +d +" "+i); System.out.println("\nConversion of double to byte."); b=(byte)d; System.out.println("d and b " +d + " " +b); } } OUTPUT : Conversion of int to byte. i and b 257 1 Conversion of double to int. d and i 323.142 323 Conversion of double to byte. d and b 323.142 67

© www.udaysatya.blogspot.com

Page 6

04 Program to demonstrate the basic Arithmetic Operations class arith { public static void main(String args[]) { int a=10,b=3; System.out.println("sum is "+(a+b)); System.out.println("difference is "+(a-b)); System.out.println("product is "+(a*b)); System.out.println("quotient is "+(a/b)); System.out.println("remainder is "+(a%b)); } } OUTPUT : sum is 13 difference is 7 product is 30 quotient is 3 remainder is 1

© www.udaysatya.blogspot.com

Page 7

05 Program to find largest of three numbers class large { public static void main(String args[]) { int a=10,b=30,c=20; System.out.println("Greatest of given 3 numbers"); if(a>b&&a>c) System.out.println(+a); else if(b>c) System.out.println(+b); else System.out.println(+c); } } OUTPUT : Greatest of given 3 numbers 30

© www.udaysatya.blogspot.com

Page 8

06 Program to print first 10 Fibonacci numbers class fib { public static void main(String args[]) { int i=9,f=0,s=1,temp; System.out.println(+f); while(i>0) { System.out.println(+s); temp=f+s; f=s; s=temp; i--; } } } OUTPUT : 0 1 1 2 3 5 8 13 21 34

© www.udaysatya.blogspot.com

Page 9

07 Program to Calculate the factorial of a number using RECURSION class Factorial { int fact(int n) { int result; if(n==1) return 1; result=fact(n-1)*n; return result; } } class Recursion { public static void main(String args[]){ Factorial f=new Factorial(); System.out.println("Factorial of 3 is " +f.fact(3)); System.out.println("Factorial of 4 is " +f.fact(4)); System.out.println("Factorial of 5 is " +f.fact(5)); } } OUTPUT : Factorial of 3 is 6 Factorial of 4 is 24 Factorial of 5 is 120

© www.udaysatya.blogspot.com

Page 10

08 Program to print prime numbers using CLA class primecla { public static void main(String s[]) { int n,r; n=Integer.parseInt(s[0]); for(int i=2;i
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF