Skip to content

Commit 778faf9

Browse files
lajitlajit
authored andcommitted
Java Prgs - First Commit
1 parent 66015cc commit 778faf9

File tree

16 files changed

+310
-0
lines changed

16 files changed

+310
-0
lines changed

JavaBasicPrograms/.classpath

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
<attribute name="test" value="true"/>
14+
</attributes>
15+
</classpathentry>
16+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
17+
<attributes>
18+
<attribute name="maven.pomderived" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="output" path="target/classes"/>
27+
</classpath>

JavaBasicPrograms/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

JavaBasicPrograms/.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>JavaBasicPrograms</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/test/java=UTF-8
4+
encoding/<project>=UTF-8
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
3+
org.eclipse.jdt.core.compiler.compliance=1.5
4+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5+
org.eclipse.jdt.core.compiler.release=disabled
6+
org.eclipse.jdt.core.compiler.source=1.5
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

JavaBasicPrograms/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>JavaCourse</groupId>
6+
<artifactId>JavaBasicPrograms</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>JavaBasicPrograms</name>
11+
<url>http://maven.apache.org</url>
12+
13+
<properties>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>junit</groupId>
20+
<artifactId>junit</artifactId>
21+
<version>3.8.1</version>
22+
<scope>test</scope>
23+
</dependency>
24+
</dependencies>
25+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package javaCrashCourse;
2+
3+
public class BankAccount {
4+
5+
Long bankAccNumber = 12345678904000l; //used Wrapper class (Long); declared value should be ended with alphabet 'l' to denote it as long datatype
6+
String holderName = "Ajit";
7+
int balanceAmt = 900; //used primitive data type (int), Here we can use the Wrapper class as 'Integer' as well
8+
9+
10+
public void getAccNumber() {
11+
System.out.println("Bank Acc # is: " + bankAccNumber);
12+
}
13+
14+
15+
public static void main(String[] args) {
16+
BankAccount account = new BankAccount(); // creating object for class name, and to call other methods
17+
account.getAccNumber();
18+
}
19+
20+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package javaCrashCourse;
2+
3+
public class ReturnData {
4+
5+
int amount = 5000;
6+
int collect = 3500;
7+
8+
/*public void collectAmount() { // change void to return data type
9+
System.out.println("Collect amount from the person: " +amount); */
10+
11+
// retunr value is nothing but collect the amount in one method, and hand it over the same value in other method
12+
13+
public Integer collectAmount() { // change void to return data type - we can use either int or Integer as return data type
14+
System.out.println("Collect amount from the person: " +amount);
15+
return amount; // Add this statement if we need to return data
16+
}
17+
18+
19+
public void nonReturn() {
20+
System.out.println("collect amt:" +collect);
21+
}
22+
23+
24+
public static void main(String[] args) {
25+
ReturnData rd = new ReturnData();
26+
int returnedAmt = rd.collectAmount();
27+
System.out.println("Returned Amount or data is: " +returnedAmt);
28+
29+
rd.nonReturn(); //we cannot store this value in any int variable as it doesnot return the value, it throws error if we try to store it in int.
30+
31+
}
32+
33+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package learnConstructors;
2+
3+
public class ChildClassConstr extends ParentClassConstr { // use extends keyword to call the parent class
4+
5+
public ChildClassConstr() {
6+
super(); // here the super() keyword is present by default for Parent - Child classes, even it is NOT visible
7+
System.out.println("Child class");
8+
}
9+
10+
public static void main(String[] args) {
11+
12+
ChildClassConstr childclass = new ChildClassConstr();
13+
14+
}
15+
16+
}

0 commit comments

Comments
 (0)