Naming convention and coding standard:
- Class --> Demo, AudiCar, SortStudentByAge
- Variable --> age, studentAge, noOfStudents
- Methods --> work(), shiftGears(), checkEvenOrOdd()
- Packages --> lowercase com, org, in…...
- Constants --> Uppercase GST, PI, ID...
What is Java?
It is an Object Oriented Programming Language because it is support all 5 OOPS concept like Class, Object, Polymorphism, Inheritance, Abstraction and Encapsulation. What is object oriented means – without class we can’t write a single line of code. Types of Programming language.
Types -- Languages -- Concept support
Structured -- C, Python -- No OOPS concept support Object based -- VB, VB Script -- Class, Object Object Oriented -- C++, JAVA, C#, Python -- Class, Object, Polymorphism, Inheritance, Abstraction and Encapsulation
Features of JAVA:
- Platform independent
- Case Sensitive
Components of JAVA:
- JDK – Java Development Kit
- JRE – Java Runtime Environment
- JVM – Java Virtual Machine
Operators:
Arithmetic Operator -> +, -, *, /, % Relational Operator ->>, >=, <, <=, ==, != Logical Operator ->&&, ||, ! Assignment/ Short hand operator -> = +=, -=, *=, /=, %= Increment/Decrement Operator -> ++, -- Ternary/Conditional Operator -> Variable = (Expression)? true: false; Operators are classified into 3 types Unary ->those operators we can use with single variable ++, --, +=,-=, *=, /=, %=, !, = Binary ->those operators we can use with at least two variables +, -, *, /, %, &&, ||, >, >=, <, <=, !=, == Ternary -> those operators we can use with at least three variables ?:
Conditional Statements:
Method Overloading:
In a class having multiple methods with the same name, but difference in arguments is called as Method Overloading. In order to achieve method overloading we need to satisfy either 1 of the following 3 rules.
- There should be a change in the Number of Arguments.
- There should be a change in the Data type of the Arguments.
- There should be a change in the order/sequence of the Data types.
Note:
- Both Static and Non-Static methods can be Overloaded.
- Yes, we can overload Main() as well, But the execution starts from the main() which accepts String[] as the argument.
- Return type might be same or different.
- Method Overloading is also referred as Compile time Polymorphism.
Scanner
- Scanner is a pre-defined class in java.util package.
- Scanner class is used to accept dynamic input from the User.
Rules to accept dynamic input from the user (or) Rules to work around with Scanner class
- Create an object of Scanner class.
- Pass System.in to the Constructor call.
Syntax:
Scanner scan = new Scanner(System.in);
- import Scanner class from java.util package.
Syntax: import java.util.Scanner;
- Make use of pre-defined methods to accept dynamic input.