java is a very popular programming language and every beginner which wants to start to learn core java. In this article, we will cover the core java syllabus so anyone can focus on these topics and learn accordingly.
In Java, programming language bais syntax and concept called as Core Java. It is the part of the Java programming language which is used for building or developing an application.
Java is a programming language and a platform. Java is a modern, robust, fully object oriented and secure programming language.
Java was developed by Sun Microsystems (which is now part of Oracle) in the year 1995. James Gosling is the father of Java. Before Java, its name was Oak. Since Oak was already a listed company, so James Gosling and his team renamed Oak with Java.
what is Platform?
Any hardware or software environment in which is required to run a program named a platform. Since Java has a runtime environment (JRE) and API so that it is called a platform.
Setting up Java
Before we start anything in java we have to set up a java environment. simply download the java and install it on your machine. If you are new to Java programming then you have to simply follow the instruction which is provided with the docs.
you have on more option to run java program online using jdoodle.com
Writing First Java Program
Creating a Hello World Program in every language is our first task, but in java, it is not a single line program. It consists of different other lines of code. Since Java is an Object-oriented language so it requires writing code inside a class.
Java Method is a group of statements to process some definite task and return the response to the caller. Methods allow us to write a reusable piece of code and dividing our program into many small units of operation. Java Method helps to clean more readable code.
Constructor in Java
Constructor in java is used to build the instance of the class. Constructors are relatively similar to methods except for two things, its name is the same as the java class name and it has no return type. Sometimes constructors are also called special methods to initialize an object.
Java Access Modifiers
Java access modifiers are used to implement access control in java. Java provides access control through these keywords – private, protected, and public. We are not using above these access modifiers, so we have another one i.e “default access“, “package-private” or “no modifier“.
In programming languages, loops are used to execute a set of statements repeatedly until some conditions become true. There are mainly three types of loops in Java.
- for loop
- while loop
- do-while loop
Data Types and Operators
- Java Autoboxing and Unboxing – Converting a primitive data type into an object of the like wrapper class is called autoboxing. For example, transforming int to Integer or converting float to Float object.
- Java Wrapper Classes– Keep primitive data types and Wrapper classes for them to keep things simple. We require wrapper classes when we need a type that will fit in the Object-Oriented Programming like Collection classes.
- Java Ternary Operator-Java ternary operator is the exclusive conditional operator that takes three operands. Java ternary operator is a one-liner replacement for if-then-else statement and used many times in java programming. We can use the ternary operator to replace the switch statement.
Any entity that has behavior and state is known as an object. For example, a table, car, bike, cycle etc. It can be physical or virtual.
An Object can be represented as an instance of a class. An object carries an address and takes up some space in the memory. Objects can communicate with each other without knowing data or code. The only important thing is the type of message accepted and the type of response returned by the objects.
Example: A cow is an object because it has states like color, name, breed, etc. as well as behaviors like wagging the tail, walking, eating, etc.
The combination of objects is called class. It is a logical entity. A class can be described as a blueprint from which you can build an individual object. Class doesn’t spend any space.
When one object obtains all the characteristics and behaviors of a parent object, it is called inheritance. It gives code reusability. It is used to produce runtime polymorphism.
A task is completed in different ways, it is known as polymorphism. For example: to add two integer numbers we can use add method, the same way we can use add a method for long data type
In Core Java Syllabus, we can use method overloading and method overriding to achieve polymorphism.
Hiding internal implementaion details and only showing functionality is known as abstraction. For example, anyone can drive a car without knowing internal working.
In core Java Syllabus, we use interface and abstract class to achieve abstraction.
Encapsulation in Core Java Syllabus OOPs Concepts
Binding code with data together into a single unit are known as encapsulation. For example, a single capsule is covered with different medicines.
A java class is the example of encapsulation. Java pojo class is the fully encapsulated class because all the data members are private here.
Coupling refers to the facts or information or dependency of another class. It occurs when classes are informed of each other. If a class has the detailed information of another class, there is a strong coupling.
In Java, we use public, private, and protected modifiers to display the visibility level of a member field, class, and method. You can use interfaces for the lower coupling because there is no concrete implementation.
Cohesion refers to the level of a component that performs a particular well-defined task. A single well-defined job is done by a highly cohesive method.
The weakly cohesive method will divide the task into separate parts. The java.io package is a highly cohesive package because it has Input/Output related classes and interface. However, the java.util package is a weakly cohesive package because it has independent classes and interfaces.
Association represents the correlation between the objects. An object can be correlated with one object or many objects. There can be four types of association among the objects:
- One to One
- One to Many
- Many to One, and
- Many to Many
Aggregation is a process to achieve Association. Aggregation represents the connection where one object contains other objects as a part of its state.
It represents the weak correlation between objects. It is called termed as a has-a relationship in Core Java Syllabus. Like, inheritance describes the is-a relationship. Aggregation is a different way to reuse objects.
The composition is also a process to achieve Association. The composition represents the connection where one object contains other objects as a part of its state.
There is a strong association between the containing object and the secondary object. It is the situation where containing objects do not have an independent survival. If you delete the origin object, all the child objects will be removed automatically.
Interface in java is one of the core Java concepts. Java Interface is a core part of the java programming language and used a lot not only in JDK but also in java design patterns. Most of the frameworks use the java interface massively.
Abstract class in Java is similar to interface except that it can include default method implementation. An abstract class can have an abstract method without a body and it may have methods with implementation also.
abstract keyword we can make an abstract class and method. Abstract class in java can’t be instantiated. An abstract class is frequently used to provide a base for subclasses to extend and implement the abstract methods and override or use the implemented methods in the abstract class.
A string is built into a series of characters. in technical words, the fundamental Java String is basically an array of characters. We are using string for containing property names. One of the primary functions of modern computer science is processing human language.
Java array is an object which holds elements of a similar data type. Additionally, The components of an array are stored in an adjacent memory location. It is a data structure where we put similar elements. We can store only a fixed amount of elements in a Core Java array.
Array in Core Java Syllabus is index-based, the first element of the array is stored at the 0th place, 2nd element is stored on 1st place and so on.