Skip to content

Commit 544513f

Browse files
main
1 parent 644ecee commit 544513f

16 files changed

+241
-1
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"5.ControlStatement\\ifElse\\ClassCodes",
1111
"6.String",
1212
"7.InputOutput",
13-
"8,Method"
13+
"8.Method",
14+
"9.Array"
1415
],
1516
"java.debug.settings.onBuildFailureProceed": true
1617
}

8.Method/ClassCodes/methodDemo10.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ClassCodes;
2+
3+
public class methodDemo10 {
4+
5+
fun(){
6+
System.out.println("In fun..!");
7+
System.out.println();
8+
}
9+
public static void main(String[] args) {
10+
11+
methodDemo10 obj = new methodDemo10();
12+
13+
obj.fun();
14+
15+
}
16+
}
17+
18+
19+
/*
20+
21+
methodDemo10.java:5: error: invalid method declaration; return type required
22+
fun(){
23+
^
24+
1 error
25+
error: compilation failed
26+
27+
*/

8.Method/ClassCodes/methodDemo11.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ClassCodes;
2+
3+
public class methodDemo11 {
4+
5+
void (){
6+
System.out.println("In fun..!");
7+
System.out.println();
8+
}
9+
public static void main(String[] args) {
10+
11+
methodDemo11 obj = new methodDemo11();
12+
13+
// obj.fun();
14+
15+
}
16+
}
17+
18+
19+
/*
20+
21+
methodDemo11.java:5: error: <identifier> expected
22+
void (){
23+
^
24+
1 error
25+
error: compilation failed
26+
27+
*/

8.Method/ClassCodes/methodDemo12.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package ClassCodes;
2+
3+
public class methodDemo12 {
4+
5+
void fun(int x){
6+
System.out.println(x);
7+
}
8+
public static void main(String[] args) {
9+
methodDemo12 obj = new methodDemo12();
10+
11+
obj.fun(10);
12+
obj.fun(10.05f);
13+
}
14+
}
15+
16+
17+
/*
18+
.\methodDemo12.java:12: error: method fun in class methodDemo12 cannot be applied to given types;
19+
obj.fun(10f);
20+
^
21+
required: int
22+
found: float
23+
reason: argument mismatch; possible lossy conversion from float to int
24+
1 error
25+
error: compilation failed
26+
*/

8.Method/ClassCodes/methodDemo13.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package ClassCodes;
2+
3+
public class methodDemo13 {
4+
5+
void fun(float x){
6+
System.out.println(x);
7+
}
8+
public static void main(String[] args) {
9+
methodDemo13 obj = new methodDemo13();
10+
11+
obj.fun(10);
12+
obj.fun(10.05f);
13+
obj.fun(true);
14+
}
15+
}
16+
17+
18+
/*
19+
20+
methodDemo13.java:13: error: method fun in class methodDemo13 cannot be applied to given types;
21+
obj.fun(true);
22+
^
23+
required: float
24+
found: boolean
25+
reason: argument mismatch; boolean cannot be converted to float
26+
1 error
27+
error: compilation failed
28+
29+
*/
30+

8.Method/ClassCodes/methodDemo6.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ClassCodes;
2+
3+
public class methodDemo6 {
4+
5+
int y =90;
6+
void fun(int x){
7+
System.out.println(x);
8+
System.out.println(y);
9+
}
10+
11+
public static void main(String[] args) {
12+
methodDemo6 obj = new methodDemo6();
13+
14+
obj.fun(10);
15+
16+
System.out.println("End of the main function...!");
17+
}
18+
}

8.Method/ClassCodes/methodDemo7.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package ClassCodes;
2+
3+
public class methodDemo7 {
4+
5+
void fun(){
6+
System.out.println();
7+
}
8+
public static void main(String[] args) {
9+
10+
methodDemo7 obj = new methodDemo7();
11+
obj.fun(x);
12+
13+
}
14+
}
15+
16+
17+
/*
18+
19+
Output:
20+
.\methodDemo7.java:11: error: method fun in class methodDemo7 cannot be applied to given types;
21+
obj.fun();
22+
^
23+
required: int
24+
found: no arguments
25+
reason: actual and formal argument lists differ in length
26+
1 error
27+
error: compilation failed
28+
29+
30+
31+
Second type:
32+
33+
.\methodDemo7.java:11: error: cannot find symbol
34+
obj.fun(x);
35+
^
36+
symbol: variable x
37+
location: class methodDemo7
38+
1 error
39+
error: compilation failed
40+
41+
*/

8.Method/ClassCodes/methodDemo8.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package ClassCodes;
2+
3+
public class methodDemo8 {
4+
5+
void fun(int x){
6+
System.out.println("In fun..!");
7+
System.out.println(x);
8+
}
9+
public static void main(String[] args) {
10+
11+
methodDemo8 obj = new methodDemo8();
12+
13+
obj.fun('A');
14+
15+
}
16+
}

8.Method/ClassCodes/methodDemo9.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package ClassCodes;
2+
3+
public class methodDemo9 {
4+
5+
void fun(char ch){
6+
System.out.println("In fun..!");
7+
System.out.println(ch);
8+
}
9+
public static void main(String[] args) {
10+
11+
methodDemo9 obj = new methodDemo9();
12+
13+
obj.fun(65);
14+
15+
}
16+
}
17+
18+
19+
/*
20+
21+
methodDemo9.java:13: error: method fun in class methodDemo9 cannot be applied to given types;
22+
obj.fun(65);
23+
^
24+
required: char
25+
found: int
26+
reason: argument mismatch; possible lossy conversion from int to char
27+
1 error
28+
error: compilation failed
29+
30+
*/

9.Array/ClassCodeArray/program1.class

540 Bytes
Binary file not shown.

9.Array/ClassCodeArray/program1.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
3+
package ClassCodeArray;
4+
5+
public class program1 {
6+
public static void main(String[] args) {
7+
8+
int arr[];
9+
10+
arr= new int[4];
11+
12+
int arr2[] = new int[0];
13+
14+
// arr2[0]=1;
15+
// System.out.println(arr2[0]);
16+
17+
18+
boolean ch[] = new boolean[5];
19+
20+
for(int i=0;i<ch.length;i++){
21+
System.out.println(ch[i]);
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)