
| public class BasicJavaExample { public static void main(String[] args) { // Variables and Data Types int number1 = 10; double number2 = 3.5; boolean isJavaFun = true; char grade = 'A'; // Operators double result = number1 + number2; int quotient = number1 / 3; // Control Structures if (isJavaFun) { System.out.println("Java is fun!"); } else { System.out.println("Java is not fun!"); } // Loops for (int i = 0; i < 5; i++) { System.out.println("Loop iteration: " + i); } // Functions (Methods) int squareResult = calculateSquare(number1); System.out.println("Square of " + number1 + " is " + squareResult); // Arrays int[] numbersArray = {1, 2, 3, 4, 5}; System.out.println("Array length: " + numbersArray.length); } } } |
| public class MathOperations { // Method to add two numbers public int add(int a, int b) { return a + b; } // Overloaded method to add three numbers public int add(int a, int b, int c) { return a + b + c; } public static void main(String[] args) { MathOperations math = new MathOperations(); // Calling the add method with two arguments int sum2Numbers = math.add(5, 10); System.out.println("Sum of two numbers: " + sum2Numbers); // Calling the add method with three arguments int sum3Numbers = math.add(5, 10, 15); System.out.println("Sum of three numbers: " + sum3Numbers); } } |
| public class MathOperations { // Method to add two integers public int add(int a, int b) { return a + b; } // Overloaded method to add two doubles public double add(double a, double b) { return a + b; } public static void main(String[] args) { MathOperations math = new MathOperations(); // Calling the add method with two integers int sumIntegers = math.add(5, 10); System.out.println("Sum of two integers: " + sumIntegers); // Calling the add method with two doubles double sumDoubles = math.add(3.5, 2.5); System.out.println("Sum of two doubles: " + sumDoubles); } } |
| Core Java | Advanced Java |
| Core Java generally covers the basic concepts related to Java Programming Language. | Advanced Java covers the advanced concepts and topics of Java programming language. |
| Core Java is used for Developing computing and desktop applications. | It is used for developing enterprise applications. |
| Core Java is considered the first step to begin Java. | It is to be considered after completing Core Java. |
| Core Java comes under Java Standard Edition. | Advanced Java comes under Java Enterprise Edition and J2EE. |
| Core Java covers topics like- OOPs, Overloading, Overriding, Exception handling, and multiple inheritance. | It covers topics like- Servlets, JSP, Web services, etc. |