Home Discussion Discuss: Constructor Overloading in Java

  • ticket systemAlfonce king April 16, 2011 at 2:17 AM

    For more than 20 years, Country Express has delivered services for all rail operations- transit, light rail, high speed rail and long haul train journey in the country. Efficiency is a daily challenge that operators of rail transportations systems face. From operation management to passenger management, operators are entrusted with the responsibility of ensuring high levels of efficiency and safety at all times. The company had recently restructured itâ??s ticketing scheme and has entrusted your group to develop a system for them embodying the following modules; 1. Registration Module Every customer has the option to register onto the system. This information is used for the reward module mentioned below. Customer details such as name and identity card are required for registration. The system will subsequently generate a unique 6 digit code which will be used by the customer to purchase train tickets. This is a one-time registration. The customer however, need not register to purchase a train ticket, in which case points will not be credited to the user for purchases of the train ticket. 2. Reward Module For every RM1.00 spent, a customer shall accumulate one point which will be credited to the account of the customerâ??s 6 digit code. 3. Ticketing Module Provides a facility to the customer to purchase ticket at the train station. There are a total of 30 stations. The cost of getting from one station to an immediate station is RM1.00. Using the same calculation, the ticket price of getting from station 1 to 6 is RM5.00. In the same way, ticket price for getting from station 10 to 30 should be RM20.00. The rates however differ at night (7 pm â?? 11 pm) and early mornings (6 am â?? 7:15 am) where a 25% discount shall apply. Children are subjected to a 50% discount regardless of the time of travel. For group purchase (more than 5 people), a 10% discount shall apply. For every 1000 points accumulated by a customer, a discount of RM5.00 shall apply. Fields required for purchasing ticket(s) â?? 6 digit code (optional), station (departure), station (arrival), travel time (24 hours), No of adults, No. of children. The system will subsequently generate the ticket price and the customer will enter the payment amount. A remainder is produced should the payment amount exceed the required amount. Apart from generating a ticket the system will also display a customerâ??s cumulative points on each generated ticket. Develop a stand alone application using Java which will observe the defined specifications. In the interface use appropriate GUI components. Make appropriate use of the Layout managers. The interface should be attractive, very user friendly, crash proof, intuitive (i.e. acts as someone would expect it to act), and reasonably realistic. Java Programming Page 1 of 3 Diploma Part 2 Asia Pacific Institute of Information Technology 2009 * You can use your own judgements and assumptions should the above requirement specification is insufficient in order to develop a realistic program. You are required to include all the assumptions that you made in your assignment.

  • javaneo May 28, 2011 at 3:20 PM

    This is very good site

  • ConstructorMd.Danish Ahmad June 24, 2011 at 2:44 PM

    Sir,Plzz explain about constructor

  • Incorrect print statements.Nikitha Nahar September 12, 2011 at 3:18 PM

    In the constructor overloading program the print statements are incorrect . They should be correspondingly for first , second , third and fourth constructor. Good program.

  • javajitendra September 23, 2011 at 5:30 PM

    public class ConstructorOverloading{ public static void main(String args[]){ Rectangle rectangle1=new Rectangle(2,4); int areaInFirstConstructor=rectangle1.first(); System.out.println(" The area of a rectangle in first constructor is : " + areaInFirstConstructor); Rectangle rectangle2=new Rectangle(5); int areaInSecondConstructor=rectangle2.second(); System.out.println(" The area of a rectangle in first constructor is : " + areaInSecondConstructor); Rectangle rectangle3=new Rectangle(2.0f); float areaInThirdConstructor=rectangle3.third(); System.out.println(" The area of a rectangle in first constructor is : " + areaInThirdConstructor); Rectangle rectangle4=new Rectangle(3.0f,2.0f); float areaInFourthConstructor=rectangle4.fourth(); System.out.println(" The area of a rectangle in first constructor is : " + areaInFourthConstructor); } } class Rectangle{ int l, b; float p, q; public Rectangle(int x, int y){ l = x; b = y; } public int first(){ return(l * b); } public Rectangle(int x){ l = x; b = x; } public int second(){ return(l * b); } public Rectangle(float x){ p = x; q = x; } public float third(){ return(p * q); } public Rectangle(float x, float y){ p = x; q = y; } public float fourth(){ return(p * q); } }

  • java programminganjali October 19, 2011 at 11:43 AM

    Write a program using overload constructor to calculate the area of square (length*length) and display it. Display I and II. I. Initialize the sides of the square=3. II. User will enter the sides ofthe square. how to solve it!

  • constructor overloadingmargub Khan October 24, 2011 at 10:40 AM

    nice example is this and i think it is one of the best

  • JAVANikhil Patel December 26, 2011 at 10:54 AM

    hello sir, my question is how to write JAVA APPLET code in NetBeans7 ?

  • javajanani6* January 7, 2012 at 1:22 PM

    how to understand java programs?

  • constructorNEERAJ KUMAE NAGER January 18, 2013 at 9:21 AM

    difference b/w overloading and overriding

  • javaBalkrishna February 15, 2012 at 3:25 PM

    i m not understand ur example please a good ex. are given

  • regarding the upper program.Sudhansh Srivastava February 17, 2012 at 12:18 PM

    how do we can minimise this constructor overloading program, and also tell me that how a user can be asked to give input to the program.

  • javavenky March 25, 2012 at 7:17 PM

    constructors metarials

  • gudmandal Reddy. Veena Reddy April 10, 2012 at 4:39 PM

    Good one

  • javaMohd Arshad May 28, 2012 at 5:59 PM

    what is polymorphim?

  • wowrajesh July 7, 2012 at 7:44 AM

    current solution for constructor overloading in java

  • javam.saravanakumar July 13, 2012 at 10:31 AM

    hi sir,how can i learn java with in short time of period..thnk u sir

  • JAVA SE &EEsunil kumar July 30, 2012 at 9:30 PM

    LEARN EVERYTHING, nice concept of constructor , thanks.....

  • thnxlee August 13, 2012 at 2:46 PM


  • Program outputNIRAV August 27, 2012 at 8:48 AM

    IN this program 14 error is there

  • HaiA Sreepriya October 1, 2012 at 1:35 PM

    Its very good example and easy to understand by the person who is very new to java

  • nicepoonam singh October 11, 2012 at 7:58 PM

    vry hlpful in my proct.......

  • querydileep July 1, 2013 at 5:43 PM

    what is meant by constructor overloading ?explain eith an example

  • querydileep July 1, 2013 at 5:44 PM

    what is meant by constructor overloading ?explain eith an example

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
Related Articles
Java Beginners

Overloading  Overloading in JAVA 

Programming Tutorials

Overloading in java
The overloading in seen with the constructor and the methods of the class The following link have all the details Constructor overloading in Java Method overloading in Java 

Java Interview Questions

Method Overloading
Method Overloading  In java can method be overloaded in different class 

Java Interview Questions

Method Overloading
Method Overloading  In java can method be overloaded in different class 

Java Interview Questions

OVERLOADING AND OVERRIDING  When Use OverLoading?When Use OverRiding Can U Explian Brifely 

Java Beginners

Method overloading in java program
Method overloading in java program  How can we use method overloading in java program?   Method overloading:?In method overloading methods... overloading- Example: public class MethodOverloading{ public void add 

Java Beginners

method overloading - Java Beginners
overloading for sum ( ) function.  class overloadingDemo { public void... }  Hi Friend, In Java, the methods having the same name within... is referred to as Method Overloading. In the given example, we have defined 

Java Server Faces Questions

overloading - Java Server Faces Questions
overloading  define overloading   Hi Friend, Overloading is the ability to define more than one method with the same name in a class. Example: class Overloading { void test() { System.out.println("Hello 

Java Beginners

Why does Java not support operator overloading?
Why does Java not support operator overloading?  Hi, Why does Java not support operator overloading? thanks 

Java Beginners

Inheritance Overloading - Java Beginners

Java Beginners

Overloading  program in method overloading it compile successfully and gives error in run time?   Hi Friend, Post your code. For more information, you can visit the following link: Method Overloading Example Thanks 

Core Java

Method Overloading Example In Java
Method Overloading Example In Java In this section we will read about overloading in Java. Method overloading in Java is achieved due to the Java supports... with the same name. The concept of method overloading allows the Java programmer 

Core Java

Constructor overloading in java
Constructor overloading in java In this section we will discuss about constructor overloading in java. Constructor overloading is not much different from... name having different signature but in case of constructor overloading you have 

Java Interview Questions

What is use of method overloading and overriding?
but by overloading, you can add values of all data types. Java Method Overloading Java...What is use of method overloading and overriding?  Method overriding...() method of Object class, we can use it with different classes. Overloading 

Java Beginners

Java Method Overloading - Java Beginners
Java Method Overloading  can method be overloaded in subclass or not?  Hi Friend, Yes A subclass can overload the methods.For Example...: http://www.roseindia.net/java/master-java/method_overloading.shtml Thanks 


Java Constructor Overloading Example
Java Constructor Overloading Example In this section we will read about the constructor overloading in Java. We will see how the constructor overloading... programming is called constructor overloading. Constructors with different 


Polymorphism : Method Overloading
In this tutorial you will learn one of polymorphism concept that is method overloading with example in Java


Constructor Overloading in Java
In this section we have discussed about Constructor Overloading in Java...;Roseindia", 10); } } Resource: Constructor Overloading in Java Java Constructor Overloading Example 


Java method overloading
Java method overloading       Example below demonstrates method overloading in java. In java  method overloading means creating more than a single method with same name 

Java Beginners

calculate volume of cube, cylinder and rectangular box using method overloading in java
method overloading in java   calculate volume of cube, cylinder and rectangular box using method overloading in java...calculate volume of cube, cylinder and rectangular box using method overloading 

Java Beginners

overloading and overriding
overloading and overriding  hello, What is the difference between overloading and overriding?   hii Overloading: Overloading is nothing but passing the different parameters to the method. Here method name is same 


Method Overloading
Method Overloading      ... and the parameter types. Java has a powerful feature which is known as method overloading. With the help of this feature we can define two methods of same name 

Java Interview Questions

method overloading
method overloading   public void test(int a); pulic void test(long a);which sutiation x.long is called 

Java Beginners

examples for overloading and overriding
examples for overloading and overriding  examples for overloading and overriding 

Core Java

Method Overloading in java
Method Overloading in java      ... implementations. In java the concept of Polymorphism is achieved in two ways: 1. Method Overloading 2. Method Overriding   Here we will discuss only 

Java Technology Tutorials

Constructor Overloading in Java
Constructor Overloading in Java     ... the constructor overloading in Java. Constructors are used to assign initial values... will be called automatically by the Java Virtual Machine (JVM). Constructor is always 

Java Interview Questions

question related to overloading
question related to overloading  what is difference between function overloading & method overloading 

Java Interview Questions

question related to overloading
question related to overloading  what is difference between function overloading & method overloading 

Java Beginners

overloading and overriding in c
overloading and overriding in c  can anyone explain the concept of overloading and overriding in reference to c programming...through an example if possible 

Java Beginners

method overloading in c program
method overloading in c program  how is method overloading in C program is different from C++ program