Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If p is defined by Pet p = new Pet(Molly, dog); Which method call converts the Pet object p into a String object? p.str( )

If p is defined by Pet p = new Pet("Molly", "dog"); Which method call converts the Pet object p into a String object?

p.str( )

p.toString( )

str(p)

String.valueOf(p)

Which of the following is a properly written getter for the instance variable animalType in the Pet class?

private String getAnimalType { return animalType; }

private String getAnimalType( ) { return animalType; }

public String getAnimalType( ) { return animalType; }

public String getAnimalType( ) { System.out.println(animalType); }

If the URL string s is defined as s = " something.html"; which statement creates a scanner which reads from the webpage with the URL string defined by s?

a. b. Scanner in1 = (new Scanner(s)).openStream( ); c. Scanner in1 = new Scanner(new URL(s)); *d. Scanner in1 = new Scanner(new URL(s).openStream( ));

Scanner in1 = new Scanner(s);

Scanner in1 = (new Scanner(s)).openStream( );

Scanner in1 = new Scanner(new URL(s));

Scanner in1 = new Scanner(new URL(s).openStream( ));

What happens if you don't close a PrintWriter object after you are finished using it?

You can't open any other PrintWriter objects.

The last page of the output buffer is not written to the output file.

Your program will not compile.

The PrintWriter object goes into an infinite loop.

What is the output of these statements? String s = "mississippi"; System.out.println(s.lastIndexOf("ssi");

2

4

5

-1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions