learn java programming structure

5
Learn Java Programming Struct ure Here in this article, it has been explained about the Java Hello World scenario with structures and features of class and this code is written to fullfill the task of printing Hello World from Java on the screen.

Upload: kanchan-mahajan

Post on 30-Jul-2016

215 views

Category:

Documents


0 download

DESCRIPTION

Learn Java programming Structure Here in this article, it has been explained about the Java Hello World scenario with structures and features of class and this code is written to fullfill the task of printing Hello World from Java on the screen.

TRANSCRIPT

Page 1: Learn java programming structure

Learn Java Programming Structure

Here in this article, it has been explained about the Java Hello World scenario with structures and features of class and this code is written to fullfill the task of printing Hello World from Java on the screen.

Page 2: Learn java programming structure

Package sct

It is a statement for package declaration. This definition of package statement shows a name space in which classes is stored. Package is used to arrange the sessions based on performance. If you bypass the package statementt, the course titles are put into the standard system, which has no name. Package statement cannot appear anywhere in system. It must be the first linee of your system or you can bypass it.

Page 3: Learn java programming structure

Public Class HelloWorld

This linee has various elements of Java development.a. public: This is accessibility modifier keyword and key phrase which informs compiler accessibility to category. Various principles of accessibility modifiers can be community, secured,private or standard (no value).b. class: This keyword and key term used to announce category. Name of class (HelloWorld) followed by this keyword and key term.

Page 4: Learn java programming structure

Program.out.println(“Hello Globe from Java”)

a. System:It is name of Java application class.b. out:It is an object which is associated with Program class.c. println:It is an application technique name which is used to deliver any String to system.d. “Hello Globe from Java”:It is String actual set as discussion to println method.More Info on Java Class:Java is an object-oriented language, which indicates that it has constructs to signify factors from the actual life. Each Java system has at least one class that knows how to do certain factors or how to signify some kind of item. For example, the easiest class, HelloWorld,knows how to welcome the globe.Sessions in Java may have techniques (or functions) and areas (or features or properties).Let’s take example of Car item which has various qualities like shade, max rate etc. along with it has features like run and quit. In Java globe we will signify it like below:Output of above CarTest java class is as below. We can run CarTest java system because it has primary technique. Main technique is place to begin for any java system performance. Operating software indicates informing the Java VIrtual Device (JVM) to “Load theclass, then begin performing its primary () technique. Keep running ’til all thecode in primary is completed.”

Page 5: Learn java programming structure

package sct;public class Car {private String color;private int maxSpeed;public String carInfo(){return color + ” Max Speed:-” + maxSpeed;}//This is constructor of Car ClassCar(String carColor, int speedLimit){this.color = carColor;this.maxSpeed =speedLimit;}}Lets create a class known as CarTestwhich will instantiate the car class object and contact carInfo way of it and see outcome.package sct;//This is car test class to instantiate and call Car objects.public class CarTest {public static void main(String[] args) {Car maruti = new Car(“Red”, 160);Car ferrari = new Car (“Yellow”, 400);System.out.println(maruti.carInfo());System.out.println(ferrari.carInfo());}}