The Artima Developer Community
Sponsored Link

Java Buzz Forum
Java Tutorial : What is a Class?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ram N

Posts: 2777
Nickname: ramram
Registered: Jul, 2014

Ram N is Java Programmer
Java Tutorial : What is a Class? Posted: Aug 4, 2015 10:45 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Ram N.
Original Post: Java Tutorial : What is a Class?
Feed Title: JAVA EE
Feed URL: http://ramj2ee.blogspot.com/feeds/posts/default?alt=rss
Feed Description: This blog has viedo tutorials and Sample codes related to below Technologies. 1.J2EE 2.Java 3.Spring 4.Hibernate 5.Database 6.Oracle 7.Mysql 8.Design Patterns
Latest Java Buzz Posts
Latest Java Buzz Posts by Ram N
Latest Posts From JAVA EE

Advertisement

Click here to watch in Youtube :
https://www.youtube.com/watch?v=JN5WWXDvQdA&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : What is a Class? 

Car.java
/**
* Car class is the blueprint from which individual car
* objects are created.
*/

public class Car
{
private String brand = null;
private String model = null;
private String color = null;

public String getBrand()
{
return brand;
}

public void setBrand(String brand)
{
this.brand = brand;
}

public String getModel()
{
return model;
}

public void setModel(String model)
{
this.model = model;
}

public String getColor()
{
return color;
}

public void setColor(String color)
{
this.color = color;
}

}
CarDemo.java
public class CarDemo
{
public static void main(String[] args)
{

/*
* Create maruthiAltok10 car object and
* set the properties
*/

Car maruthiAltok10 = new Car();

maruthiAltok10.setBrand("Maruthi Alto");
maruthiAltok10.setModel("k10");
maruthiAltok10.setColor("Orange");

displayCarInformation(maruthiAltok10);

/*
* Create swift car object and
* set the properties
*/

Car swift = new Car();

swift.setBrand("Swift");
swift.setModel("ZDI");
swift.setColor("Red");

displayCarInformation(swift);

/*
* Create maruthiAlto800 car object and
* set the properties
*/

Car maruthiAlto800 = new Car();

maruthiAlto800.setBrand("Maruthi Alto");
maruthiAlto800.setModel("800");
maruthiAlto800.setColor("Blue");

displayCarInformation(maruthiAlto800);

}

private static void displayCarInformation(Car car)
{
System.out.println("Car Brand : " + car.getBrand());
System.out.println("Car Model : " + car.getModel());
System.out.println("Car Color : " + car.getColor());
System.out.println("--------------------------------");
}

}
Output
Car Brand : Maruthi Alto
Car Model : k10
Car Color : Orange
--------------------------------
Car Brand : Swift
Car Model : ZDI
Car Color : Red
--------------------------------
Car Brand : Maruthi Alto
Car Model : 800
Car Color : Blue
--------------------------------

To Download CarDemoClassApp Project Click the below link
https://sites.google.com/site/javaee4321/java/CarDemoClassApp.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Read: Java Tutorial : What is a Class?

    Topic: Using Java 8 CompletableFuture and Rx-Java Observable Previous Topic   Next Topic Topic: DevOps ROI

    Sponsored Links



    Google
      Web Artima.com   

    Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use