X hits on this document

109 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 views109
Page views109
Page last viewedTue Dec 06 18:29:59 UTC 2016
Pages46
Paragraphs816
Words2901

Comments