2m 1. Java Features 2. Basic oops concepts 3. Command line arguments 4. public static void main 4M 1. Variable and its types. 2. Overloading concept 3. Arrays in Java 8M 1. Data types -primitive and non primitive 2. Control structures 1. Java Features ● Simple : Java is a simple language because its syntax is simple, clean, and easy to understand. Complex and ambiguous concepts of C++ are either eliminated or re-implemented in Java. For example, pointer and operator overloading are not used in Java. ● Object-Oriented : In Java, everything is in the form of the object. It means it has some data and behavior. A program must have at least one class and object. ● Robust : Java makes an effort to check errors at run time and compile time. It uses a strong memory management system called garbage collector. Exception handling and garbage collection features make it strong. ● Secure : Java is a secure programming language because it has no explicit pointer and programs run in the virtual machine. Java contains a security manager that defines the access of Java classes. ● Platform-Independent : Java provides a guarantee that code writes once and runs anywhere. This byte code is platform-independent and can be run on any machine. ● Portable : Java Byte code can be carried to any platform. No implementation- dependent features. Everything related to storage is predefined, for example, the size of primitive data types. ● High Performance : Java is an interpreted language. Java enables high performance with the use of the Just-In-Time compiler. ● Distributed : Java also has networking facilities. It is designed for the distributed environment of the internet because it supports TCP/IP protocol. It can run over the internet. EJB and RMI are used to create a distributed system. ● Multi-threaded : Java also supports multi-threading. It means to handle more than one job at a time. 2. Basic OOPs Concept a. Classes : . Collection of objects . Template used to create objects and to define object type . Syntax: class <classname> { Data Members Member Methods } . Example: class Dog { char color; int age; void bark(); } b. Objects . Real world entity . Has state, behavior, identity . State represents data of an object . Behavior represents the functionality . Syntax to create an object: classname objname = new classname(); . Example: Dog d = new Dog(); c. Inheritance . Provides reusability of code. subclass (child) - the class that inherits from another class superclass (parent) - the class being inherited from . uses extends keyword . Syntax: public class Animal { ....... ...... } public class Dog extends Animal { ...... ...... } public class Cat extends Animal { ....... ....... } d. Polymorphism . Process of using one single method for multiple use . Also called as “overloading” . Can be used by creating multiple methods with the same name but with different numbers of arguments or data types. 3. Command line arguments The java command-line argument is an argument passed at the time of running the java program. The arguments passed from the console can be received in the java program and it can be used as an input. You can pass N numbers of arguments from the command prompt. . Example: class Example { public static void main(String args[]) { System.out.println("Your first argument is: "+args[0]); } } compile:> javac Example.java run:> java Example sample O/P: Your first argument is: sample 4. public static void main(): a) public: So that JVM can execute the method from anywhere. b) static : The main method is to be called without an object. The modifiers public and static can be written in either order. c) void : The main method doesn’t return anything. d) main() : Name configured in the JVM. The main method must be inside the class definition. The compiler executes the codes starting always from the main function. e) String[] : The main method accepts a single argument, i.e., an array of elements of type String. 4M 1. Variables and its types a. Variable is a data container that saves the data values during Java program execution. Every variable is assigned a data type that designates the type and quantity of value it can hold. A variable is a memory location name for the data. A variable is a name given to a memory location.