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

Answer, a program to find the area under curve y=f(x) between x=a and x=b,i...

a program to find the area under curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits of a and b

In javascript what is event handling and inline event, In JavaScript, what ...

In JavaScript, what is event handling? What are the two categories of events? In java script we could capture events on do a few operation on the basis of which particular even

Explain about the interpreter in java, Machines should have Java interprete...

Machines should have Java interpreter for the Java byte code to get implemented. Linking is a very simple process and this feature helps while developing applications. Java compile

Design a bond class, In the lectures, we have written programs for bond pri...

In the lectures, we have written programs for bond pricing in discrete time. We have also talked about the theory for bond pricing and yields in continuous time. In this exercise,

What does it mean that a method or class is abstract, What does it mean tha...

What does it mean that a method or class is abstract? An abstract class cannot be instantiated. Abstract methods may only be included in abstract classes. However, an abstract

What is an immutable object, What is an immutable object? An immutable ...

What is an immutable object? An immutable object is one that we can't change once it's created. Steps involved in creation of an immutable object are: Make all of its data f

What are the design goals of java, What are the Design Goals of Java Ma...

What are the Design Goals of Java Massive growth of the Internet and World-Wide Web leads us to a completely new way of looking at development of software which can run on diff

Coding, code for error correction and detection using even odd parity

code for error correction and detection using even odd parity

Explain rmi, RMI is a set of APIs that permits to build distributed applica...

RMI is a set of APIs that permits to build distributed applications. RMI uses interfaces to describe remote objects to turn local method invocations into remote method invocations.

Simon game project, i''m trying to make a code to make the simon says game ...

i''m trying to make a code to make the simon says game and i can''t figure it outt

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