-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
786 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.subho.wipro</groupId> | ||
<artifactId>pjp.tm12</artifactId> | ||
<version>1.0</version> | ||
|
||
<packaging>jar</packaging> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>github</id> | ||
<name>GitHub Subhrodip Apache Maven Packages</name> | ||
<url>https://maven.pkg.github.com/ohbus/PJP</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<name>pjp.tm12</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.subho.wipro.pjp.tm12; | ||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class App | ||
{ | ||
public static void main( String[] args ) | ||
{ | ||
System.out.println( "Hello World!" ); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Java8/src/main/java/com/subho/wipro/pjp/tm12/DateTimeAPI/Assigment01.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.subho.wipro.pjp.tm12.DateTimeAPI; | ||
|
||
//Write a program to display today's date and the date after ten days. | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Assigment01 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
LocalDate date = LocalDate.now(); | ||
System.out.println("Todays Date : " + date); | ||
System.out.println("Date after 10 days : " + date.plusDays(10)); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
Java8/src/main/java/com/subho/wipro/pjp/tm12/DateTimeAPI/Assigment02.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.subho.wipro.pjp.tm12.DateTimeAPI; | ||
|
||
// Write a program to find the date of next month second Sunday. | ||
|
||
import java.time.DayOfWeek; | ||
import java.time.LocalDate; | ||
import java.time.temporal.TemporalAdjusters; | ||
|
||
public class Assigment02 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
LocalDate secondSunday = LocalDate.now().plusMonths(1).with(TemporalAdjusters.dayOfWeekInMonth(2, DayOfWeek.SUNDAY)); | ||
System.out.println(secondSunday); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
Java8/src/main/java/com/subho/wipro/pjp/tm12/DateTimeAPI/Assigment03.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.subho.wipro.pjp.tm12.DateTimeAPI; | ||
|
||
//Write a program to calculate your experience (no of years, no of months & no of days) in Wipro. | ||
|
||
import java.time.LocalDate; | ||
import java.time.Period; | ||
|
||
public class Assigment03 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
LocalDate joiningDate = LocalDate.of(2015,5,5); | ||
Period d = Period.between(joiningDate,LocalDate.now()); | ||
int days = d.getDays(); | ||
int months = d.getMonths(); | ||
int years = d.getYears(); | ||
System.out.println("Experience : " + years + " years " + months + " months " + days + " days." ); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
Java8/src/main/java/com/subho/wipro/pjp/tm12/DateTimeAPI/Assigment04.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.subho.wipro.pjp.tm12.DateTimeAPI; | ||
|
||
//Write a program to check whether the current year is a leap year. | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Assigment04 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
LocalDate date = LocalDate.now(); | ||
if(date.isLeapYear()) | ||
System.out.println("Current Year is a leap year"); | ||
else | ||
System.out.println("Current Year is not a leap year"); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
Java8/src/main/java/com/subho/wipro/pjp/tm12/DateTimeAPI/Assigment05.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.subho.wipro.pjp.tm12.DateTimeAPI; | ||
|
||
// Write a program to display the current time and the time after 25 minutes. | ||
|
||
import java.time.LocalTime; | ||
|
||
public class Assigment05 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
LocalTime time = LocalTime.now(); | ||
System.out.println("Time : " + time ); | ||
System.out.println("Time after 25 minutes : " + time.plusMinutes(25)); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
Java8/src/main/java/com/subho/wipro/pjp/tm12/DateTimeAPI/Assigment06.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.subho.wipro.pjp.tm12.DateTimeAPI; | ||
|
||
//Write a program to display the current time and the time before 5 hours and 30 minutes. | ||
|
||
import java.time.LocalTime; | ||
|
||
public class Assigment06 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
LocalTime time = LocalTime.now(); | ||
System.out.println("Time : " + time ); | ||
System.out.println("Time before 5 hours 30 minutes : " + time.minusMinutes(30).minusHours(5) ); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
Java8/src/main/java/com/subho/wipro/pjp/tm12/ForEach/Assignment01.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/*Write a program to create an ArrayList and add the weekdays. | ||
Iterate and print all the elements using forEach method | ||
*/ | ||
|
||
package com.subho.wipro.pjp.tm12.ForEach; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
public class Assignment01 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
ArrayList<String> arrL = new ArrayList<String>( | ||
Arrays.asList("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")); | ||
|
||
arrL.forEach(day -> System.out.println(day)); | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
Java8/src/main/java/com/subho/wipro/pjp/tm12/ForEach/Assignment02.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* Create an ArrayList and add 5 Employee(id,name,address,salary) objects. | ||
Retrieve the objects from the ArrayList using forEach and print the Employee details. | ||
*/ | ||
|
||
package com.subho.wipro.pjp.tm12.ForEach; | ||
|
||
import java.util.ArrayList; | ||
|
||
class Employee { | ||
int id; | ||
double salary; | ||
String address, name; | ||
|
||
Employee(int id, double salary, String name, String address) { | ||
this.id = id; | ||
this.salary = salary; | ||
this.name = name; | ||
this.address = address; | ||
} | ||
} | ||
|
||
public class Assignment02 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
Employee emp1 = new Employee(1, 100.0, "James", "Kolkata"); | ||
Employee emp2 = new Employee(2, 200.0, "Kames", "Colkata"); | ||
Employee emp3 = new Employee(3, 300.0, "Lames", "Lolkata"); | ||
Employee emp4 = new Employee(4, 400.0, "Names", "Tolkata"); | ||
Employee emp5 = new Employee(5, 500.0, "Pames", "Bolkata"); | ||
|
||
ArrayList<Employee> empList = new ArrayList<Employee>(); | ||
empList.add(emp1); | ||
empList.add(emp2); | ||
empList.add(emp3); | ||
empList.add(emp4); | ||
empList.add(emp5); | ||
|
||
empList.forEach(emp -> System.out.println( | ||
"ID : " + emp.id + " Name : " + emp.name + " Salary : " + emp.salary + " Address : " + emp.address)); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
Java8/src/main/java/com/subho/wipro/pjp/tm12/Interfaces/Assignment01.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.subho.wipro.pjp.tm12.Interfaces; | ||
|
||
/*Create an interface Vehicle with a default method message() that returns nothing and prints "Inside Vehicle". | ||
Create an interface FourWheeler with a default method message() that returns nothing and prints "Inside FourWheeler". | ||
Create a class Car implementing these two interfaces. | ||
In this class, Override the message() method and call the message() method of the Vehicle interface using super keyword. | ||
Instantiate the class, call the message method and observe the output. | ||
*/ | ||
|
||
interface Vehicle { | ||
default void message() { | ||
System.out.println("Inside Vehicle"); | ||
} | ||
} | ||
|
||
interface FourWheeler { | ||
default void message() { | ||
System.out.println("Inside FourWheeler"); | ||
} | ||
} | ||
|
||
class Car implements Vehicle, FourWheeler { | ||
|
||
@Override | ||
public void message() { | ||
// TODO Auto-generated method stub | ||
Vehicle.super.message(); | ||
} | ||
|
||
} | ||
|
||
public class Assignment01 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
Car car = new Car(); | ||
car.message(); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
Java8/src/main/java/com/subho/wipro/pjp/tm12/Interfaces/Assignment02.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.subho.wipro.pjp.tm12.Interfaces; | ||
|
||
/*Create an interface Test with an abstract method "int myFunction". | ||
This function takes three integer parameters. | ||
Write a program to create two Test reference variables t1 and t2. | ||
t1 should add three integer parameters and t2 should multiply three integer parameters, using lambda expression. | ||
Call myFunction using t1 and t2 reference variables, by passing three integer values and print the result. | ||
*/ | ||
|
||
interface Test { | ||
int myFunction(int x, int y, int z); | ||
} | ||
|
||
public class Assignment02 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
Test t1 = (x, y, z) -> (x + y + z); | ||
Test t2 = (x, y, z) -> (x * y * z); | ||
|
||
System.out.println(t1.myFunction(10, 20, 30)); | ||
System.out.println(t2.myFunction(10, 20, 30)); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
Java8/src/main/java/com/subho/wipro/pjp/tm12/LambdaExpressions/Assignment01.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.subho.wipro.pjp.tm12.LambdaExpressions; | ||
|
||
/*Create an ArrayList al and add 25 random numbers. | ||
Write a code to print all the prime numbers that are present in it, using lambda expression. | ||
*/ | ||
|
||
import java.util.ArrayList; | ||
import java.util.Random; | ||
|
||
public class Assignment01 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
ArrayList<Integer> al = new ArrayList<Integer>(); | ||
Random random = new Random(); | ||
for(int i = 0; i < 25; i++){ | ||
al.add(random.nextInt(100)); | ||
} | ||
System.out.println("Array : " +al.toString()); | ||
System.out.print("Prime Nos : "); | ||
al.forEach(num -> { | ||
boolean isPrime = true; | ||
for (int i = 2; i <= (int) Math.sqrt(num); i++) { | ||
if (num % i == 0) { | ||
isPrime = false; | ||
break; | ||
} | ||
} | ||
System.out.print(isPrime ? num + " " : ""); | ||
}); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
Java8/src/main/java/com/subho/wipro/pjp/tm12/LambdaExpressions/Assignment02.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.subho.wipro.pjp.tm12.LambdaExpressions; | ||
|
||
/*Create an ArrayList al and add 10 different words. | ||
Write a code to print all the Strings in reverse order, using lambda expression. | ||
*/ | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Assignment02 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
ArrayList<StringBuffer> al = new ArrayList<StringBuffer>(); | ||
String[] wordsArray = { "Java", "Python", "C++", "C", "JavaScript", "Go", "Rust", "Bash", "Haskell", "Ruby" }; | ||
|
||
for (String word : wordsArray) { | ||
StringBuffer sb = new StringBuffer(word); | ||
al.add(sb); | ||
} | ||
al.forEach(word -> System.out.print(word.reverse() + " ")); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
Java8/src/main/java/com/subho/wipro/pjp/tm12/LambdaExpressions/Assignment03.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.subho.wipro.pjp.tm12.LambdaExpressions; | ||
|
||
/*Create an ArrayList al and add 10 different words. | ||
Write a code to print all the Strings whose length is odd, using lambda expression. | ||
*/ | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
public class Assignment03 { | ||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
ArrayList<String> al = new ArrayList<String>( | ||
Arrays.asList("Java", "Python", "C++", "C", "JavaScript", "Go", "Rust", "Bash", "Haskell", "Ruby")); | ||
|
||
al.forEach(word -> System.out.print((word.length() % 2 != 0) ? word + " " : "")); | ||
} | ||
|
||
} |
Oops, something went wrong.