Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/HierarchicalI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Animal2{
void eat(){System.out.println("eating...");}
}
class Dog2 extends Animal2{
void bark(){System.out.println("barking...");}
}
class Cat extends Animal2{
void meow(){System.out.println("meowing...");}
}
public class HierarchicalI {
public static void main(String args[]){
Cat c=new Cat();
c.meow();
c.eat();
//c.bark();//C.T.Error
}}
21 changes: 21 additions & 0 deletions src/LocalGlobalScope.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class LocalGlobalScope {
static int x = 11;
private int y = 33;
public void method1(int x)
{
LocalGlobalScope t = new LocalGlobalScope();
this.x = 22;
y = 44;

System.out.println("Test.x: " + LocalGlobalScope.x);
System.out.println("t.x: " + t.x);
System.out.println("t.y: " + t.y);
System.out.println("y: " + y);
}

public static void main(String args[])
{
LocalGlobalScope t = new LocalGlobalScope();
t.method1(5);
}
}
2 changes: 1 addition & 1 deletion src/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
System.out.println("Hello Abhinav!");
}
}
27 changes: 27 additions & 0 deletions src/MinMaxValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class MinMaxValue {
public static void main(String args[])
{
System.out.println(
"S.No.\t Data Type\t Size\t Min. Value\t\t Max. Value\t");
System.out.println("1\t Byte\t\t" + Byte.SIZE
+ "\t" + Byte.MIN_VALUE
+ "\t\t\t" + Byte.MAX_VALUE);
System.out.println("2\t Short\t\t" + Short.SIZE
+ "\t" + Short.MIN_VALUE
+ "\t\t\t" + Short.MAX_VALUE);
System.out.println("3\t Integer\t" + Integer.SIZE
+ "\t" + Integer.MIN_VALUE
+ "\t\t" + Integer.MAX_VALUE);
System.out.println("4\t Float\t\t" + Float.SIZE
+ "\t" + Float.MIN_VALUE
+ "\t\t\t" + Float.MAX_VALUE);
System.out.println("5\t Long\t\t" + Long.SIZE
+ "\t" + Long.MIN_VALUE + "\t"
+ Long.MAX_VALUE);
System.out.println("6\t Double\t" + Double.SIZE
+ "\t" + Double.MIN_VALUE
+ "\t\t" + Short.MAX_VALUE);
System.out.println("7\t Character\t"
+ Character.SIZE);
}
}
16 changes: 16 additions & 0 deletions src/MultilevelInheritance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Animal1{
void eat(){System.out.println("eating...");}
}
class Dog1 extends Animal1{
void bark(){System.out.println("barking...");}
}
class BabyDog extends Dog1{
void weep(){System.out.println("weeping...");}
}
public class MultilevelInheritance {
public static void main(String args[]){
BabyDog d=new BabyDog();
d.weep();
d.bark();
d.eat();
}}
22 changes: 22 additions & 0 deletions src/StackandHeap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Emp {
int id;
String emp_name;

public Emp(int id, String emp_name) {
this.id = id;
this.emp_name = emp_name;
}
}

public class StackandHeap {
private static Emp StackandHeap(int id, String emp_name) {
return new Emp(id, emp_name);
}

public static void main(String[] args) {
int id = 21;
String name = "Maddy";
Emp person_ = null;
person_ = StackandHeap(id, name);
}
}
13 changes: 13 additions & 0 deletions src/array.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class array {
public static void main(String args[]){
int a[]=new int[5];//declaration and instantiation
a[0]=10;//initialization
a[1]=20;
a[2]=70;
a[3]=40;
a[4]=50;
//traversing array
for(int i=0;i<a.length;i++)//length is the property of array
System.out.println(a[i]);
}}

20 changes: 20 additions & 0 deletions src/contructor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
public class contructor {
int id;
String name;
//creating a parameterized constructor
contructor(int i,String n){
id = i;
name = n;
}
//method to display the values
void display(){System.out.println(id+" "+name);}

public static void main(String args[]){
//creating objects and passing values
contructor s1 = new contructor(111,"Karan");
contructor s2 = new contructor(222,"Aryan");
//calling method to display the values of object
s1.display();
s2.display();
}
}
18 changes: 18 additions & 0 deletions src/defaultValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public class defaultValue {
static byte a;
static short b;
static char c;
static float d;
static double e;
static boolean f;

public static void main(String[] args) {

System.out.println("Default value of byte Type = " +a);
System.out.println("Default value of short Type = " +b);
System.out.println("Default value of char Type = " +c);
System.out.println("Default value of float type = " +d);
System.out.println("Default value of double Type = " +e);
System.out.println("Default value of boolean Type = " +f);
}
}
11 changes: 11 additions & 0 deletions src/inheritance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Employee{
float salary=40000;
}
class Programmer extends Employee{
int bonus=10000;
public static void main(String args[]){
Programmer p=new Programmer();
System.out.println("Programmer salary is:"+p.salary);
System.out.println("Bonus of Programmer is:"+p.bonus);
}
}