What is java :-
- Java is a popular programming language.
- Java is used to develop mobile apps, web apps, desktop apps, games and much more.
- Java is developed by James Gosling and released by Sun Microsystems in 1995.
- It is also owned by oracle.
Feature of java :-
- It is platform independent language.
- It is portable java language supported.
- It is reusable.
- It is easy to learn and simple to use.
- It is open-source and free.
- It is secure, fast and powerful.
Application of java :-
- Mobile Application
- Web development
- Games
- Database Connect
- Web server
Access Modifiers :-
Access Modifier |
Within Class |
Within Package |
Outside Package by subclass only |
Outside Package |
Private |
Yes |
No |
No |
No |
Default |
Yes |
Yes |
No |
No |
Protected |
Yes |
Yes |
Yes |
No |
Public |
Yes |
Yes |
Yes |
Yes |
Basic Syntax of java :-
public class class_name
{
public
static void main(String args[])
{
System.out.println(“ ”);
// statement
}
}
Explain The Syntax :-
Class Declaration:
- public: This is an access modifier. It means that this class is accessible from other classes.
- class: This keyword is used to declare a class in Java.
- ClassName: This is the name of the class. By convention, class names in Java start with an uppercase letter.
Main Method Declaration:
- public: This access modifier means that the method can be called from outside the class.
- static: This means that the method belongs to the class rather than an instance of the class. It can be called without creating an object of the class.
- void: This indicates that the method does not return any value.
- main: This is the name of the method. It's the entry point of any Java application.
- String[] args: This is the parameter passed to the main method. It's an array of strings that stores command-line arguments.
Method Body:
- System.out.println(" ");: This line prints a string to the console.
- System: This is a final class in java.lang package.
- out: This is a static member of the System class and is an instance of PrintStream.
- println(): This is a method of PrintStream class. It prints the argument passed to it, followed by a new line.