Skip to content

Commit 8a01a59

Browse files
Main
1 parent ed3ea2a commit 8a01a59

File tree

17 files changed

+241
-18
lines changed

17 files changed

+241
-18
lines changed

1.DataType/ClassCodes/rogram11.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ClassCodes;
2+
3+
class Demo{
4+
5+
public static void main(String[] args) {
6+
7+
long a = 1234567891;
8+
9+
System.out.println((a/1000)*1000);
10+
}
11+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package StringClassCodes;
2+
3+
class StringPermutations {
4+
public static void main(String[] args) {
5+
String input = "abc";
6+
generatePermutations(input);
7+
}
8+
9+
public static void generatePermutations(String input) {
10+
permute(input, 0, input.length() - 1);
11+
}
12+
13+
private static void permute(String str, int left, int right) {
14+
if (left == right) {
15+
System.out.println(str);
16+
} else {
17+
for (int i = left; i <= right; i++) {
18+
str = swap(str, left, i);
19+
permute(str, left + 1, right);
20+
str = swap(str, left, i); // backtrack
21+
}
22+
}
23+
}
24+
25+
private static String swap(String str, int i, int j) {
26+
char[] charArray = str.toCharArray();
27+
char temp = charArray[i];
28+
charArray[i] = charArray[j];
29+
charArray[j] = temp;
30+
return new String(charArray);
31+
}
32+
}

10.String/UserDefineMethods/program.java

Whitespace-only changes.

11.Classes&Objects/Static/StaticBlock/program8.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
public class program8 {
55

66
static {
7-
// a= 90;
7+
a= 90;
88
System.out.println(a);
99
}
1010
public static void main(String[] args) {

13.Polymorphism/MethodOverloading/2_MethodOverloading.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ int fun(int x){ // fun(int)
99
return x;
1010
}
1111

12-
// float fun(int y){ // fun(int)
13-
// return y;
14-
// }
12+
float fun(int y,int x){ // fun(int)
13+
return y;
14+
}
1515
}
1616

1717

14.Abstraction&Interface/AbstractClass/5_Abstract.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ abstract class Parent5{
55
int x =10;
66
static int y = 20;
77

8+
Parent5(){
9+
System.out.println("In Abstarct Constructor..!");
10+
}
11+
812
void career(){
913
System.out.println("Doctor");
1014
}

14.Abstraction&Interface/AbstractClass/6_AbstractRealEx.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
abstract class CompanyName{
44

5+
int x =10;
6+
57
abstract void EmpRole();
68

79
void workingTime(){
Binary file not shown.
Binary file not shown.
Binary file not shown.

14.Abstraction&Interface/Interface/20_interfaceVariables.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,40 @@
33
interface parent20{
44

55
int x =10;
6-
void fun();
6+
default void fun(){
7+
8+
System.out.println("Fun parent");
9+
}
710
}
811

912

1013
interface p{
1114
int x =20;
15+
16+
default void fun(){
17+
System.out.println("Fun child");
18+
}
1219
}
1320

1421

15-
class child20 implements parent20,p{
22+
class child20 implements p{
1623

1724
int x =30;
18-
public void fun(){
19-
System.out.println(x);
20-
System.out.println(p.x);
21-
System.out.println(parent20.x);
22-
}
23-
}
24-
25+
// public void fun(){
26+
// System.out.println(x);
27+
// System.out.println(p.x);
28+
// System.out.println(parent20.x);
29+
// }
2530

26-
class Client20{
2731
public static void main(String[] args) {
28-
parent20 obj = new child20();
29-
obj.fun();
32+
3033
}
3134
}
35+
36+
37+
// class Client20{
38+
// public static void main(String[] args) {
39+
// p obj = new child20();
40+
// obj.fun();
41+
// }
42+
// }
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package Interface;
2+
3+
// interface Parent{
4+
5+
// default void fun(){
6+
// System.out.println("In Parent fun..!");
7+
// }
8+
// }
9+
10+
interface Child{
11+
12+
default void fun(){
13+
System.out.println("In child fun");
14+
}
15+
}
16+
17+
class Demo implements Child{
18+
19+
public static void main(String[] args) {
20+
21+
Child obj = new Demo();
22+
obj.fun();
23+
}
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package Interface;
2+
3+
public class program {
4+
public static void main(String[] args) {
5+
6+
String str = "absc174fbbds45c897";
7+
int count = 0;
8+
int cnt = 0;
9+
for(int i=0;i<str.length();i++){
10+
11+
if(str.charAt(i)>=48 && str.charAt(i)<=57){
12+
while(i<str.length() && str.charAt(i)>=48 && str.charAt(i)<=57){
13+
count++;
14+
i++;
15+
}
16+
cnt++;
17+
18+
}
19+
}
20+
21+
System.out.println(count+cnt);
22+
}
23+
}

16.ExceptionHandling/TryCatchFinally/FinallyBlock/2_NullPointerException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ public static void main(String[] args) {
1414
System.out.println("Start Main");
1515
NullPointerExcept1 obj = new NullPointerExcept1();
1616
obj.fun();
17-
obj = null;
18-
obj = null;
17+
// obj = null;
18+
// obj = null;
1919

2020
try {
2121

2222
obj.gun();
23+
// return;
2324
} catch (ArithmeticException e) {
2425

2526
System.out.println("Null Pointer Exception Occured...!");

18.Package/addFun/Demo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package addFun;
2+
3+
class MyClass{
4+
5+
protected void fun(){
6+
System.out.println("In Fun Method");
7+
}
8+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package collection.list.arrayList;
2+
3+
import java.util.ArrayList;
4+
import java.util.Collections;
5+
import java.util.Comparator;
6+
import java.util.List;
7+
8+
9+
10+
class VirtualMemory{
11+
12+
int pcNo;
13+
14+
int totalMemory;
15+
16+
int availableMemory;
17+
18+
int usedMemory;
19+
20+
VirtualMemory(int pcNo,int totalMemory,int availableMemory, int usedMemory){
21+
this.pcNo = pcNo;
22+
this.totalMemory = totalMemory;
23+
this.availableMemory = availableMemory;
24+
this.usedMemory = usedMemory;
25+
}
26+
27+
public String toString(){
28+
return "{TotalMemory : "+this.totalMemory+" , UsedMemory: "+this.usedMemory+" , AvailableMemory: "+this.availableMemory+" }\n";
29+
}
30+
}
31+
32+
class Disk{
33+
34+
List<VirtualMemory>disk = new ArrayList<>();
35+
36+
void addMemory(){
37+
38+
}
39+
40+
}
41+
42+
class sortByAvailbaleMemory implements Comparator<VirtualMemory>{
43+
44+
@Override
45+
public int compare(VirtualMemory o1, VirtualMemory o2) {
46+
return -(o1.availableMemory - o2.availableMemory);
47+
}
48+
49+
}
50+
51+
class ClientMemory{
52+
53+
public static void main(String[] args) {
54+
55+
// List<VirtualMemory>ls = new ArrayList<>();
56+
57+
// ls.add(new VirtualMemory(10, 3, 10-3));
58+
// ls.add(new VirtualMemory(20, 3, 20-3));
59+
// ls.add(new VirtualMemory(15, 7, 15-7));
60+
61+
// Collections.sort(ls,new sortByAvailbaleMemory());
62+
63+
// System.out.println(ls);
64+
65+
// VirtualMemory vm = ls.get(0);
66+
67+
// System.out.println(vm);
68+
69+
List<Disk>ls = new ArrayList<>();
70+
71+
ls.add(new Disk(new VirtualMemory(10, 3, 10-3)));
72+
ls.add(new Disk(new VirtualMemory(20, 3, 20-3)));
73+
ls.add(new Disk(new VirtualMemory(15, 7, 15-7)));
74+
75+
System.out.println(ls);
76+
}
77+
}

2.Loop/Pattern/program36.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
/*
3+
* 1
4+
* 2 9
5+
* 3 8 10
6+
* 4 7 11 14
7+
* 5 6 12 13 15
8+
*
9+
*/
10+
11+
12+
13+
package Pattern;
14+
15+
public class program36 {
16+
public static void main(String[] args) {
17+
18+
String str = "1121";
19+
int x = Integer.parseInt(str);
20+
int count = 1;
21+
for(int i=0;i<5;i++){
22+
23+
for(int j=0;j<=i;j++){
24+
System.out.print(count+" ");
25+
count++;
26+
}
27+
System.out.println();
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)