Skip to content

Commit 7283681

Browse files
committed
Migrate development environment from Windows to macOS and continue project updates
- Shifted primary development environment from Windows to macOS to ensure better performance, stability, and streamlined workflow for Java development. - Removed OS-specific metadata and ensured platform-agnostic project compatibility. - Normalized line endings to LF for cross-platform consistency. - Verified and adjusted file paths, permissions, and encoding settings to suit macOS environment. - Cleaned up unnecessary Windows-generated files and updated Git configuration accordingly. - Future commits and development will now be managed entirely from macOS. This migration ensures a cleaner, more consistent setup moving forward and prepares the project for scalable development across Unix-based systems. Future development will continue on macOS for a smoother, Unix-based experience. Signed-off-by: Someshdiwan <[email protected]>
1 parent a29e2db commit 7283681

18 files changed

+345
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="jdk" jdkName="23" jdkType="JavaSDK" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
public class AddOverloadDemo {
2+
3+
// Method 1: No parameters, adds hardcoded numbers
4+
void add() {
5+
int a = 10, b = 20;
6+
int sum = a + b;
7+
System.out.println("Sum (no parameters): " + sum);
8+
}
9+
10+
// Method 2: Two parameters, returns the sum
11+
int add(int x, int y) {
12+
return x + y;
13+
}
14+
15+
// Method 3: Three parameters, prints the sum
16+
void add(int x, int y, int z) {
17+
int sum = x + y + z;
18+
System.out.println("Sum (three parameters): " + sum);
19+
}
20+
21+
// Main method to call all add methods
22+
public static void main(String[] args) {
23+
AddOverloadDemo obj = new AddOverloadDemo();
24+
25+
obj.add(); // Calls method with no parameters
26+
27+
int result = obj.add(15, 25); // Calls method with two parameters
28+
System.out.println("Sum (two parameters): " + result);
29+
30+
obj.add(5, 10, 20); // Calls method with three parameters
31+
}
32+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*Printing Output from Functions
2+
A Method can also directly print output to the console using print statements.
3+
However, this doesn't provide any data back to the caller in a way that can be used elsewhere in the program.
4+
The primary purpose here is to display information, not to provide data for further processing.
5+
6+
Check the example below which gives the same output as the code above:*/
7+
8+
public class FunctionCC5
9+
{
10+
public static void main(String[] args)
11+
{
12+
printSquare(5);
13+
}
14+
15+
// User-defined method to print the square of a number
16+
public static void printSquare(int num)
17+
{
18+
int squareResult = num * num;
19+
System.out.println("Square of " + num + " is: " + squareResult);
20+
}
21+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public class FunctionsCC
2+
{
3+
public static void calculateSum(int num1, int num2)
4+
{
5+
int result = num1 + num2;
6+
System.out.println(result);
7+
}
8+
public static void main(String [] args)
9+
{
10+
calculateSum(3, 4);
11+
}
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class FunctionsCC2 {
2+
public static int calculateSum(int num1, int num2){
3+
return num1 + num2;
4+
}
5+
public static void main(String[] args)
6+
{
7+
System.out.println(calculateSum(3, 4));
8+
}
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//Print the returned value directly.
2+
3+
public class FunctionsCC3 {
4+
public static int calculateSum(int num1, int num2)
5+
{
6+
return num1 + num2;
7+
}
8+
public static void main(String[] args) {
9+
System.out.println(calculateSum(3, 4));
10+
}
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//Storing the returned value in a variable.
2+
public class FunctionsCC4
3+
{
4+
public static int calculateSum(int num1, int num2)
5+
{
6+
return num1 + num2;
7+
}
8+
public static void main(String[] args)
9+
{
10+
int sum = 0;
11+
sum = calculateSum(3, 4);
12+
int avg = sum / 2;
13+
System.out.println(avg);
14+
}
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//Specifying the return type is important.
2+
3+
4+
public class FunctionsCC5 {
5+
public static int /*return type we can change it into any type.*/ calculateSum (int num1, int num2)
6+
{
7+
return num1 + num2;
8+
}
9+
public static void main (String[] Args){
10+
System.out.println(calculateSum(3, 4));
11+
}
12+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
Can you write a Java class from scratch that demonstrates method overloading for an add() method?
3+
4+
The class should include:
5+
6+
A method add() with no parameters that adds two hardcoded numbers and prints the result.
7+
A method add(int x, int y) that returns the sum of two integers.
8+
A method add(int x, int y, int z) that prints the sum of three integers.
9+
A main method where you create an object of the class and call all three overloaded methods with sample inputs.
10+
Bonus: Explain how Java determines which overloaded method to call.
11+
*/
12+
13+
class HardCodes11
14+
{
15+
void add() //No Parameters.
16+
{
17+
int a, b, c;
18+
a=3;
19+
b=5;
20+
c=a+b;
21+
System.out.println(c);
22+
}
23+
24+
int add(int x, int y) //Two Parameters.
25+
{
26+
int z;
27+
z=x+y;
28+
return z;
29+
}
30+
31+
void add(int x, int y, int z) //Three Parameters.
32+
{
33+
int m = x+y+z;
34+
System.out.println(m);
35+
}
36+
37+
public static void main(String[] args) {
38+
HardCodes11 obj = new HardCodes11();
39+
40+
obj.add();
41+
int num;
42+
43+
obj.add(12,45,67);
44+
num = obj.add(100,45);
45+
46+
System.out.println(num);
47+
}
48+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public class IntToBinary {
2+
public static void main(String[] args)
3+
{
4+
int x = 5;
5+
System.out.println(Integer.toBinaryString(x));
6+
System.out.println(Integer.toHexString(x));
7+
}
8+
}

0 commit comments

Comments
 (0)