diff --git a/LogicalProgram/.classpath b/LogicalProgram/.classpath new file mode 100644 index 0000000..e461bea --- /dev/null +++ b/LogicalProgram/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/LogicalProgram/.project b/LogicalProgram/.project new file mode 100644 index 0000000..b259315 --- /dev/null +++ b/LogicalProgram/.project @@ -0,0 +1,17 @@ + + + LogicalProgram + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/LogicalProgram/.settings/org.eclipse.jdt.core.prefs b/LogicalProgram/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/LogicalProgram/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/LogicalProgram/src/com/akash/abstractExample/Rectangle.java b/LogicalProgram/src/com/akash/abstractExample/Rectangle.java new file mode 100644 index 0000000..5732adc --- /dev/null +++ b/LogicalProgram/src/com/akash/abstractExample/Rectangle.java @@ -0,0 +1,19 @@ +package com.akash.abstractExample; + +public class Rectangle extends Shape{ + + @Override + public void calculateArea() { + // TODO + + } + + // its Example of Abstraction and Inheritance + public static void main(String arg[]) { + Rectangle rectangle = new Rectangle(); + rectangle.display(); + //rectangle.b = 20; + + } + +} diff --git a/LogicalProgram/src/com/akash/abstractExample/Shape.java b/LogicalProgram/src/com/akash/abstractExample/Shape.java new file mode 100644 index 0000000..dbf3217 --- /dev/null +++ b/LogicalProgram/src/com/akash/abstractExample/Shape.java @@ -0,0 +1,11 @@ +package com.akash.abstractExample; + +abstract class Shape { + final int b = 20; + public void display() { + System.out.println("This is display method....."); + } + + abstract public void calculateArea(); + +} diff --git a/LogicalProgram/src/com/akash/banking/Deposit.java b/LogicalProgram/src/com/akash/banking/Deposit.java new file mode 100644 index 0000000..6ecae2b --- /dev/null +++ b/LogicalProgram/src/com/akash/banking/Deposit.java @@ -0,0 +1,5 @@ +package com.akash.banking; + +public class Deposit { + +} diff --git a/LogicalProgram/src/com/akash/banking/Withdrawal.java b/LogicalProgram/src/com/akash/banking/Withdrawal.java new file mode 100644 index 0000000..32bce4c --- /dev/null +++ b/LogicalProgram/src/com/akash/banking/Withdrawal.java @@ -0,0 +1,5 @@ +package com.akash.banking; + +public class Withdrawal { + +} diff --git a/LogicalProgram/src/com/akash/designPattern/Singleton.java b/LogicalProgram/src/com/akash/designPattern/Singleton.java new file mode 100644 index 0000000..c661acf --- /dev/null +++ b/LogicalProgram/src/com/akash/designPattern/Singleton.java @@ -0,0 +1,18 @@ +package com.akash.designPattern; + +public class Singleton { + + private static Singleton singleton = null; + //private static Singleton singleton = null; + + private Singleton() { + // constructor + } + + public static Singleton getInstance() { + if(singleton == null) { + singleton = new Singleton(); + } + return singleton; + } +} \ No newline at end of file diff --git a/LogicalProgram/src/com/akash/designPattern/SingletonDemo.java b/LogicalProgram/src/com/akash/designPattern/SingletonDemo.java new file mode 100644 index 0000000..7e3ec5d --- /dev/null +++ b/LogicalProgram/src/com/akash/designPattern/SingletonDemo.java @@ -0,0 +1,18 @@ +package com.akash.designPattern; + +public class SingletonDemo { + + private static SingletonDemo singleton = null; + + private SingletonDemo() { + // TODO + } + + public static SingletonDemo getInstance() { + if(singleton == null) { + singleton = new SingletonDemo(); + } + return singleton; + } + +} diff --git a/LogicalProgram/src/com/akash/inheritance/poly/Animal.java b/LogicalProgram/src/com/akash/inheritance/poly/Animal.java new file mode 100644 index 0000000..238e084 --- /dev/null +++ b/LogicalProgram/src/com/akash/inheritance/poly/Animal.java @@ -0,0 +1,13 @@ +package com.akash.inheritance.poly; + +public class Animal { + + private int a; + int b; + + public void onEating() { + System.out.println(" This is eating method of Animal class "); + } + + +} diff --git a/LogicalProgram/src/com/akash/inheritance/poly/Dog.java b/LogicalProgram/src/com/akash/inheritance/poly/Dog.java new file mode 100644 index 0000000..6b57fe8 --- /dev/null +++ b/LogicalProgram/src/com/akash/inheritance/poly/Dog.java @@ -0,0 +1,15 @@ +package com.akash.inheritance.poly; + +public class Dog extends Animal{ + int c; // new instance variable of class Dog + + public void onEating() { + // overridden method + System.out.println("this is method onEating of class Dog"); + } + public void onAction() { + super.onEating(); + System.out.println("This is method onAction of class Dog"); + } + +} diff --git a/LogicalProgram/src/com/akash/inheritance/poly/Runner.java b/LogicalProgram/src/com/akash/inheritance/poly/Runner.java new file mode 100644 index 0000000..f6f5854 --- /dev/null +++ b/LogicalProgram/src/com/akash/inheritance/poly/Runner.java @@ -0,0 +1,23 @@ +package com.akash.inheritance.poly; + +public class Runner { + + public static void main(String[] arg) { + Animal animal = new Animal(); + Dog dog = new Dog(); + + Animal ani = new Dog(); + System.out.println(" Animal: + : + "); + + ani.onEating(); // Dog class + + System.out.println(" Animal : + : "); + //dog.onEating(); + + dog.onAction(); + + animal.onEating(); + + } + +} diff --git a/LogicalProgram/src/com/akash/overriding/Doctor.java b/LogicalProgram/src/com/akash/overriding/Doctor.java new file mode 100644 index 0000000..4a65100 --- /dev/null +++ b/LogicalProgram/src/com/akash/overriding/Doctor.java @@ -0,0 +1,10 @@ +package com.akash.overriding; + +public class Doctor { + + public void treatPatient(){ + //treatPatient method + System.out.println("Doctor is executed........."); + } + +} diff --git a/LogicalProgram/src/com/akash/overriding/MainClass.java b/LogicalProgram/src/com/akash/overriding/MainClass.java new file mode 100644 index 0000000..30b8e42 --- /dev/null +++ b/LogicalProgram/src/com/akash/overriding/MainClass.java @@ -0,0 +1,18 @@ +package com.akash.overriding; + +public class MainClass { + + public static void main(String[] args) { + Doctor doctor = new Doctor(); + doctor.treatPatient(); + + Surgeon surgeon = new Surgeon(); + surgeon.treatPatient(); + + Doctor s = new Surgeon(); + System.out.println(" -----"); + s.treatPatient(); /*Base class Surgeon*/ + + } + +} diff --git a/LogicalProgram/src/com/akash/overriding/Surgeon.java b/LogicalProgram/src/com/akash/overriding/Surgeon.java new file mode 100644 index 0000000..4e8cad1 --- /dev/null +++ b/LogicalProgram/src/com/akash/overriding/Surgeon.java @@ -0,0 +1,9 @@ +package com.akash.overriding; + +public class Surgeon extends Doctor{ + + public void treatPatient() { + System.out.println("Surgeon is executed.........."); + } + +} diff --git a/LogicalProgram/src/com/akash/staticBlock/Demo.java b/LogicalProgram/src/com/akash/staticBlock/Demo.java new file mode 100644 index 0000000..bcbebc4 --- /dev/null +++ b/LogicalProgram/src/com/akash/staticBlock/Demo.java @@ -0,0 +1,21 @@ +package com.akash.staticBlock; + +public class Demo { + + int a; + static int b; + + static { + System.out.println("Hello"); + } + + public static void main(String[] args) { + String abc ="abc"; + String abcd = "abcd"; + + System.out.println(abc+" "+abcd); + + System.out.println("Value of a = "+ new Demo().a); + System.out.println("Value of b = "+ b); + } +} diff --git a/LogicalProgram/src/com/akash/stringBuffer/StringBufferDemo.java b/LogicalProgram/src/com/akash/stringBuffer/StringBufferDemo.java new file mode 100644 index 0000000..05a3f73 --- /dev/null +++ b/LogicalProgram/src/com/akash/stringBuffer/StringBufferDemo.java @@ -0,0 +1,18 @@ +package com.akash.stringBuffer; + +public class StringBufferDemo { + + public static void main(String[] args) { + StringBuffer stringBuffer = new StringBuffer("Akash"); + int length1 = stringBuffer.length(); + System.out.println(":::: "+length1); + stringBuffer.append(" Kumar"); + int length = stringBuffer.length(); + int capacity = stringBuffer.capacity(); + System.out.println(capacity+ " : : capacity"); + System.out.println(length); + + System.out.println(stringBuffer); + } + +} diff --git a/LogicalProgram/src/com/akash/stringBuffer/StringBuffereReverse.java b/LogicalProgram/src/com/akash/stringBuffer/StringBuffereReverse.java new file mode 100644 index 0000000..0f73811 --- /dev/null +++ b/LogicalProgram/src/com/akash/stringBuffer/StringBuffereReverse.java @@ -0,0 +1,16 @@ +package com.akash.stringBuffer; + +public class StringBuffereReverse { + + public static void main(String[] args) { + StringBuffer stringBuffer = new StringBuffer("Akash"); + + stringBuffer.reverse(); + + System.out.println(stringBuffer); + + stringBuffer.delete(0, 2); + System.out.println(stringBuffer); + + } +} diff --git a/LogicalProgram/src/com/akash/stringbuilder/StringBuilderDemo.java b/LogicalProgram/src/com/akash/stringbuilder/StringBuilderDemo.java new file mode 100644 index 0000000..ab6c3d1 --- /dev/null +++ b/LogicalProgram/src/com/akash/stringbuilder/StringBuilderDemo.java @@ -0,0 +1,21 @@ +package com.akash.stringbuilder; + +public class StringBuilderDemo { + + public static void main(String[] args) { + + StringBuilder str = new StringBuilder("Akash Kumar"); + str.append(" Singh"); + + System.out.println("String : "+ str.toString()); + System.out.println("String without : "+str); + + str.reverse(); + System.out.println(str); + + + + + } + +}