Create objects of student class by calling default, JAVA Programming

Assignment Help:

Create objects of student class by calling default

Create objects of student class by calling default, parameterize and copy constructor Call student class different methods on these objects.

Student client code

// File Test.java

 

/* This class create Student class objects and demonstrates

how to call various methods on objects

*/

public class Test{

 

public static void main (String args[]){

 

// Make two student obejcts

Student s1 = new Student("ali", 15);

Student s2 = new Student(); //call to default costructor

 

s1.print(); // display ali and 15

s2.print(); // display not set and 100

 

s2.setName("usman");

s2.setRollNo(20);

 

System.out.print("Student name:" + s2.getName());

System.out.println(" rollNo:" + s2.getRollNo());

 

System.out.println("calling copy constructor");

Student s3 = new Student(s2); //call to copy constructor

 

s2.print();

s3.print();

s3.setRollNo(-10); //Roll No of s3 would be set to 100

s3.print();

/*NOTE: public vs. private

A statement like "b.rollNo = 10;" will not compile in a

client of the Student class when rollNo is declared

protected or private

*/

} //end of main

} //end of class

#question..

 


Related Discussions:- Create objects of student class by calling default

Convert US Dollars to Canadian Dollars, How to write a program that convert...

How to write a program that converts US dollars into Canadian dollars.The program let the user enter an amount in US dollars and display it equivalent value in Canadian dollars whe

Write an aspect that counts different kinds of method calls, Problem statem...

Problem statement Part 1 Write an aspect that counts different kinds of method calls in a Java program. Your aspect should meet the following requirements:  The aspect should ma

Functions in javascript, The following set of short questions will focus on...

The following set of short questions will focus on getting you familiar with JavaScript functions. All functions and testing should appear in a single XHTML 1.0 Strict page. All

Develop a customer relationship management system, You are a newly recruite...

You are a newly recruited programmer, working for an IT company. This company won a contract to develop a Customer Relationship Management System (CRM) for a major retailer. The CR

State the java programmer efficiency, State the Java Programmer Efficiency ...

State the Java Programmer Efficiency Faster Development Building an application in Java takes about 50% less time than in C or C++. So, faster time to market Java is said to

Describe overriding methods, Describe Overriding Methods ? Assume that...

Describe Overriding Methods ? Assume that one day you've just finished your Car class. It's been plugged into your traffic simulation that is chugging along merrily simulating

Illustrate java management extensions (jmx)?, JMX framework can enhance the...

JMX framework can enhance the manageability of your application by  1. Monitoring your application for critical events, performance problems, and error condition statistics. E.g

Explain difference between the boolean and operator, What is the difference...

What is the difference between the Boolean & operator and the && operator? If an expression including the Boolean & operator is evaluated, both operands are evaluated. Then the

Develop android geolocation service app, Project Description: Develop an...

Project Description: Develop an android service app that will run on the background. The app has to get the users location (longitude and latitude) every 5 minutes or when th

Explain continue statement with example, Explain continue statement with ex...

Explain continue statement with example? It is sometimes essential to exit from the middle of a loop. Sometimes you'll need to begin over at the top of the loop. Sometimes you'

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd