package com.mrbear;
/**
* Hello world!
*
*/
public class App
{
public String getHim(String name)
{
return name;
}
public String getHim(Object object)
{
return "Object";
}
public static void main( String[] args )
{
System.out.println( "Hello World!" );
App app = new App();
System.out.println( app.getHim("Brian Goetz"));
System.out.println( app.getHim((Object) "James Gosling"));
Object object = "Joshua Bloch";
System.out.println( app.getHim(object));
}
}
What does the program above print to its screen?
/**
* Hello world!
*
*/
public class App
{
public String getHim(String name)
{
return name;
}
public String getHim(Object object)
{
return "Object";
}
public static void main( String[] args )
{
System.out.println( "Hello World!" );
App app = new App();
System.out.println( app.getHim("Brian Goetz"));
System.out.println( app.getHim((Object) "James Gosling"));
Object object = "Joshua Bloch";
System.out.println( app.getHim(object));
}
}
References
- Oracle The Java™ Tutorials - Defining Methods
- https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
No comments:
Post a Comment