X hits on this document

164 views

0 shares

0 downloads

0 comments

25 / 46

© S. Uchitel, 2004

25

Creating and Using Objects: Example

What is the output of the following code?

{

System.out.println(“Programing II”);

Lecturer y = new Lecturer(“Seb”);

y.setLogin(“su2”);

System.out.println(y.getLogin());

y = new Lecturer(“Ale”);

y.setLogin(“ar3”);

String login = y.getLogin();

System.out.println(login);

}

Programming II su2 ar3

:Lecturer

name = “Seb”

login = “su2”

y:Lecturer

name = “Ale”

login = “ar3”

Note that the first object ends   up being inaccessible. (No reference variable points to it).

Document info
Document views164
Page views164
Page last viewedMon Jan 23 01:31:25 UTC 2017
Pages46
Paragraphs816
Words2901

Comments