├── Demo.java ├── Logical.java ├── README.md ├── Ternary.java ├── Types of inheritance in java.docx ├── Types of inheritance in java_wordpad.docx ├── applet ├── DisplayImage.class ├── DisplayImage.html ├── DisplayImage.java ├── First.class ├── First.java ├── First1.class ├── First1.java ├── GraphicsDemo.class ├── GraphicsDemo.java ├── Lifecycle of Java Applet.docx ├── download.jpg ├── myapplet.html ├── myapplet1.html ├── prog2.html ├── second.class └── second.java ├── demo1.java ├── demo2.java ├── demo3.java ├── demo4.java ├── demo5.java ├── demo6.java ├── demo7.java ├── demo8.java ├── java_package.docx ├── operators.java └── operators1.java /Demo.java: -------------------------------------------------------------------------------- 1 | public class Demo { 2 | public static void main(String[] args) 3 | { 4 | // byte type 5 | byte b = 20; 6 | System.out.println("b= " + b); 7 | 8 | // short type 9 | short s = 20; 10 | System.out.println("s= " + s); 11 | 12 | // int type 13 | int i = 20; 14 | System.out.println("i= " + i); 15 | 16 | // long type 17 | long l = 20; 18 | System.out.println("l= " + l); 19 | } 20 | } -------------------------------------------------------------------------------- /Logical.java: -------------------------------------------------------------------------------- 1 | // Java code to illustrate 2 | // logical AND operator 3 | 4 | import java.io.*; 5 | 6 | class Logical { 7 | public static void main(String[] args) 8 | { 9 | // initializing variables 10 | int a = 10, b = 20, c = 20, d = 0; 11 | 12 | // Displaying a, b, c 13 | System.out.println("Var1 = " + a); 14 | System.out.println("Var2 = " + b); 15 | System.out.println("Var3 = " + c); 16 | 17 | // using logical AND to verify 18 | // two constraints 19 | if ((a < b) && (b == c)) { 20 | d = a + b + c; 21 | System.out.println("The sum is: " + d); 22 | } 23 | else 24 | System.out.println("False conditions"); 25 | } 26 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/README.md -------------------------------------------------------------------------------- /Ternary.java: -------------------------------------------------------------------------------- 1 | // Java program to find largest among two 2 | // numbers using ternary operator 3 | 4 | import java.io.*; 5 | 6 | class Ternary { 7 | public static void main(String[] args) 8 | { 9 | 10 | // variable declaration 11 | int n1 = 5, n2 = 10, max; 12 | 13 | System.out.println("First num: " + n1); 14 | System.out.println("Second num: " + n2); 15 | 16 | // Largest among n1 and n2 17 | max = (n1 > n2) ? n1 : n2; 18 | 19 | // Print the largest number 20 | System.out.println("Maximum is = " + max); 21 | } 22 | } -------------------------------------------------------------------------------- /Types of inheritance in java.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/Types of inheritance in java.docx -------------------------------------------------------------------------------- /Types of inheritance in java_wordpad.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/Types of inheritance in java_wordpad.docx -------------------------------------------------------------------------------- /applet/DisplayImage.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/applet/DisplayImage.class -------------------------------------------------------------------------------- /applet/DisplayImage.html: -------------------------------------------------------------------------------- 1 | import java.awt.*; 2 | import java.applet.*; 3 | 4 | public class DisplayImage extends Applet 5 | { 6 | Image picture; 7 | public void init() 8 | { 9 | picture = getImage(getDocumentBase(),"sonoo.jpg"); 10 | } 11 | 12 | public void paint(Graphics g) { 13 | g.drawImage(picture, 30,30, this); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /applet/DisplayImage.java: -------------------------------------------------------------------------------- 1 | import java.awt.*; 2 | import java.applet.*; 3 | 4 | public class DisplayImage extends Applet 5 | { 6 | Image picture; 7 | public void init() 8 | { 9 | picture = getImage(getDocumentBase(),"download.jpg"); 10 | } 11 | 12 | public void paint(Graphics g) { 13 | g.drawImage(picture, 30,30, this); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /applet/First.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/applet/First.class -------------------------------------------------------------------------------- /applet/First.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | import java.applet.Applet; 4 | import java.awt.Graphics; 5 | 6 | public class First extends Applet 7 | { 8 | public void paint(Graphics g) 9 | { 10 | g.drawString("welcome",150,150); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /applet/First1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/applet/First1.class -------------------------------------------------------------------------------- /applet/First1.java: -------------------------------------------------------------------------------- 1 | //program to illustrate applet 2 | 3 | import java.applet.Applet; 4 | import java.awt.Graphics; 5 | public class First1 extends Applet{ 6 | 7 | public void paint(Graphics g){ 8 | g.drawString("welcome to applet",150,150); 9 | } 10 | 11 | } 12 | /* 13 | 14 | 15 | */ 16 | -------------------------------------------------------------------------------- /applet/GraphicsDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/applet/GraphicsDemo.class -------------------------------------------------------------------------------- /applet/GraphicsDemo.java: -------------------------------------------------------------------------------- 1 | import java.applet.Applet; 2 | import java.awt.*; 3 | 4 | public class GraphicsDemo extends Applet 5 | { 6 | public void paint(Graphics g) 7 | { 8 | g.setColor(Color.red); 9 | g.drawString("Welcome",50, 50); 10 | g.drawLine(20,30,20,300); 11 | g.drawRect(70,100,30,30); 12 | g.fillRect(170,100,30,30); 13 | g.drawOval(70,200,30,30); 14 | g.setColor(Color.green); 15 | g.fillOval(170,200,30,30); 16 | g.drawArc(90,150,30,30,30,270); 17 | g.fillArc(270,150,30,30,0,180); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /applet/Lifecycle of Java Applet.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/applet/Lifecycle of Java Applet.docx -------------------------------------------------------------------------------- /applet/download.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/applet/download.jpg -------------------------------------------------------------------------------- /applet/myapplet.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /applet/myapplet1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /applet/prog2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /applet/second.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/applet/second.class -------------------------------------------------------------------------------- /applet/second.java: -------------------------------------------------------------------------------- 1 | //program to illustrate applet 2 | 3 | import java.applet.Applet; 4 | import java.awt.Graphics; 5 | public class second extends Applet{ 6 | 7 | public void paint(Graphics g){ 8 | g.drawString("welcome to applet",150,150); 9 | g.drawString("HELLO",50,50); 10 | } 11 | 12 | } 13 | /* 14 | 15 | 16 | */ 17 | -------------------------------------------------------------------------------- /demo1.java: -------------------------------------------------------------------------------- 1 | public class Demo1 { 2 | 3 | public static void main(String[] args) 4 | { 5 | // float type 6 | float f = 20.25f; 7 | System.out.println("f= " + f); 8 | 9 | // double type 10 | double d = 20.25; 11 | System.out.println("d= " + d); 12 | } 13 | } -------------------------------------------------------------------------------- /demo2.java: -------------------------------------------------------------------------------- 1 | public class Demo2 { 2 | public static void main(String[] args) { 3 | 4 | char ch = 'S'; 5 | System.out.println(ch); 6 | 7 | char ch2 = '&'; 8 | System.out.println(ch2); 9 | 10 | char ch3 = '$'; 11 | System.out.println(ch3); 12 | 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /demo3.java: -------------------------------------------------------------------------------- 1 | public class Demo3 { 2 | 3 | public static void main(String[] args) { 4 | 5 | boolean t = true; 6 | System.out.println(t); 7 | 8 | boolean f = false; 9 | System.out.println(f); 10 | 11 | }} -------------------------------------------------------------------------------- /demo4.java: -------------------------------------------------------------------------------- 1 | import java.lang.*; 2 | import java.util.*; 3 | 4 | class demo4{ 5 | public static void main(String ar[]) 6 | { 7 | System.out.println("PRIMITIVE DATA TYPES\n"); 8 | int x = 10; 9 | int y = x; 10 | System.out.print("Initially: "); 11 | System.out.println("x = " + x + ", y = " + y); 12 | 13 | // Here the change in the value of y 14 | // will not affect the value of x 15 | y = 30; 16 | 17 | System.out.print("After changing y to 30: "); 18 | System.out.println("x = " + x + ", y = " + y); 19 | System.out.println( 20 | "**Only value of y is affected here " 21 | + "because of Primitive Data Type\n"); 22 | 23 | System.out.println("REFERENCE DATA TYPES\n"); 24 | int[] c = { 10, 20, 30, 40 }; 25 | 26 | // Here complete reference of c is copied to d 27 | // and both point to same memory in Heap 28 | int[] d = c; 29 | 30 | System.out.println("Initially"); 31 | System.out.println("Array c: " 32 | + Arrays.toString(c)); 33 | System.out.println("Array d: " 34 | + Arrays.toString(d)); 35 | 36 | // Modifying the value at 37 | // index 1 to 50 in array d 38 | System.out.println("\nModifying the value at " 39 | + "index 1 to 50 in array d\n"); 40 | d[1] = 50; 41 | 42 | System.out.println("After modification"); 43 | System.out.println("Array c: " 44 | + Arrays.toString(c)); 45 | System.out.println("Array d: " 46 | + Arrays.toString(d)); 47 | System.out.println( 48 | "**Here value of c[1] is also affected " 49 | + "because of Reference Data Type\n"); 50 | } 51 | } -------------------------------------------------------------------------------- /demo5.java: -------------------------------------------------------------------------------- 1 | // Java Program to Illustrate Unary - Operator 2 | 3 | // Importing required classes 4 | import java.io.*; 5 | 6 | // Main class 7 | class demo5 { 8 | 9 | // Main driver method 10 | public static void main(String[] args) 11 | { 12 | // Declaring a custom variable 13 | int n1 = 20; 14 | 15 | // Printing the above variable 16 | System.out.println("Number = " + n1); 17 | 18 | // Performing unary operation 19 | n1 = -n1; 20 | 21 | // Printing the above result number 22 | // after unary operation 23 | System.out.println("Result = " + n1); 24 | } 25 | } -------------------------------------------------------------------------------- /demo6.java: -------------------------------------------------------------------------------- 1 | // Java Program to Illustrate Unary NOT Operator 2 | 3 | // Importing required classes 4 | import java.io.*; 5 | 6 | // Main class 7 | class demo6 { 8 | 9 | // Main driver method 10 | public static void main(String[] args) 11 | { 12 | // Initializing variables 13 | boolean cond = true; 14 | int a = 10, b = 1; 15 | 16 | // Displaying values stored in above variables 17 | System.out.println("Cond is: " + cond); 18 | System.out.println("Var1 = " + a); 19 | System.out.println("Var2 = " + b); 20 | 21 | // Displaying values stored in above variables 22 | // after applying unary NOT operator 23 | System.out.println("Now cond is: " + !cond); 24 | System.out.println("!(a < b) = " + !(a < b)); 25 | System.out.println("!(a > b) = " + !(a > b)); 26 | } 27 | } -------------------------------------------------------------------------------- /demo7.java: -------------------------------------------------------------------------------- 1 | // Java code to illustrate "=" operator 2 | 3 | import java.io.*; 4 | 5 | class demo7 { 6 | public static void main(String[] args) 7 | { 8 | // Declaring variables 9 | int num; 10 | String name; 11 | 12 | // Assigning values 13 | num = 10; 14 | name = "GeeksforGeeks"; 15 | 16 | // Displaying the assigned values 17 | System.out.println("num is assigned: " + num); 18 | System.out.println("name is assigned: " + name); 19 | } 20 | } -------------------------------------------------------------------------------- /demo8.java: -------------------------------------------------------------------------------- 1 | // Java Program to Illustrate equal to Operator 2 | 3 | // Importing I/O classes 4 | import java.io.*; 5 | 6 | // Main class 7 | class GFG { 8 | 9 | // Main driver method 10 | public static void main(String[] args) 11 | { 12 | // Initializing variables 13 | int var1 = 5, var2 = 10, var3 = 5; 14 | 15 | // Displaying var1, var2, var3 16 | System.out.println("Var1 = " + var1); 17 | System.out.println("Var2 = " + var2); 18 | System.out.println("Var3 = " + var3); 19 | 20 | // Comparing var1 and var2 and 21 | // printing corresponding boolean value 22 | System.out.println("var1 == var2: " 23 | + (var1 == var2)); 24 | 25 | // Comparing var1 and var3 and 26 | // printing corresponding boolean value 27 | System.out.println("var1 == var3: " 28 | + (var1 == var3)); 29 | } 30 | } -------------------------------------------------------------------------------- /java_package.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RashmivernekarN/Java-Programs/32f3502f110cc9c64c15aca2373ece41c701648f/java_package.docx -------------------------------------------------------------------------------- /operators.java: -------------------------------------------------------------------------------- 1 | // Java program to illustrate 2 | // bitwise operators 3 | 4 | public class operators { 5 | public static void main(String[] args) 6 | { 7 | // Initial values 8 | int a = 5; 9 | int b = 7; 10 | 11 | // bitwise and 12 | // 0101 & 0111=0101 = 5 13 | System.out.println("a&b = " + (a & b)); 14 | 15 | // bitwise or 16 | // 0101 | 0111=0111 = 7 17 | System.out.println("a|b = " + (a | b)); 18 | 19 | // bitwise xor 20 | // 0101 ^ 0111=0010 = 2 21 | System.out.println("a^b = " + (a ^ b)); 22 | 23 | // bitwise not 24 | // ~00000000 00000000 00000000 00000101=11111111 11111111 11111111 11111010 25 | // will give 2's complement (32 bit) of 5 = -6 26 | System.out.println("~a = " + ~a); 27 | 28 | // can also be combined with 29 | // assignment operator to provide shorthand 30 | // assignment 31 | // a=a&b 32 | a &= b; 33 | System.out.println("a= " + a); 34 | } 35 | } -------------------------------------------------------------------------------- /operators1.java: -------------------------------------------------------------------------------- 1 | // Left Shifting a byte value 2 | 3 | class GFGoperators1 { 4 | public static void main(String[] args) 5 | { 6 | byte a = 64, b; 7 | int i; 8 | 9 | i = a << 2; 10 | b = (byte)(a << 2); 11 | System.out.println("Original value of a: " + a); 12 | System.out.println("i and b: " + i + " " + b); 13 | } 14 | } --------------------------------------------------------------------------------