which are true of following code???

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
sulakshana
Posts: 14
Joined: Thu Dec 22, 2016 8:55 pm
Contact:

which are true of following code???

Post by sulakshana »

Package aquarium.*;
public class Water{
public String toString() { return ""; }
}
Package aquarium.*;
public class Shark{
static int numfins;
static Water water;
public static void Main(String[] args){
String s1 = water.toString();
String s2 = numfins.toString();} }
The answer for this question is numfins.to
String() does not compile because numfins is a primitive;
What is static Water water ; in this question .... Why two water words are used here...

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: which are true of following code???

Post by admin »

Water with capital W is the class name. water with small w is the static variable name. This variable is being declared to be of type Water.

BTW, what happened when you asked your doubt to the author of the book that you have taken this from? Are they not responding?
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 53 guests