Analyze the code snippet below:package package1;import;import;import;import;import;public class WebPageTextReader {public static void main(String[] args) {try {URL url = new URL("");// read text returned by serverBufferedReader in = new BufferedReader(newInputStreamReader(url.openStream()));String line;while ((line = in.readLine()) != null) {//System.out.println(line);double d = Double.parseDouble(line);System.out.println(d);}in.close();}catch (MalformedURLException e) {System.out.println("Malformed URL: " + e.getMessage());}catch (IOException e) {System.out.println("I/O Error: " + e.getMessage());}}} Answer the following questions:2.1. How many classes are involved in this code? What are they?2.2. How many objects of these classes are created in this code? (Hint: look for a new operator)2.3. What do you think this program does?

Asked Nov 6, 2019

Analyze the code snippet below:

package package1;
public class WebPageTextReader {
public static void main(String[] args) {
try {
URL url = new URL("");
// read text returned by server
BufferedReader in = new BufferedReader(new

String line;
while ((line = in.readLine()) != null) {
double d = Double.parseDouble(line);

catch (MalformedURLException e) {
System.out.println("Malformed URL: " + e.getMessage());
catch (IOException e) {
System.out.println("I/O Error: " + e.getMessage());


Answer the following questions:
2.1. How many classes are involved in this code? What are they?

2.2. How many objects of these classes are created in this code? (Hint: look for a new operator)

2.3. What do you think this program does? 


Expert Answer

Step 1

There is only one class involved in this code.

The class name is: WebPageTextReader.


After the class keyword whatever name or a valid identifier comes in considered as class name.

Code line where class name lies:

public class WebPageTextReader 

In this above line WebPageTextReader comes after the class keyword. Hence, it is class name.

Step 2

There is only one object created in this code.

Object: url


The object is an instance of any class. The new operator is used to create an object in java.

Syntax to create object:

Class_name object_name= new Class_name();

Code line where object lies:

URL url = new URL("

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in


Computer Science


Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add

Q: OF 2019 x + X PG Difference between two given ti X fn Course: CSI-14...

A: Program in C to calculate the order price by entering number of books, price of a book, tax per book...


Q: Hi, I am required to: Create an array of 100 integers using a random generator. ( 1 for loop) Provi...

A: The given java program will follow the following rubrics:Importing essential header files.Creating a...


Q: How would you modify the dynamic programming algorithm for the coin collecting problem if some cells...

A: Coin collecting problemIn a n-m board, several coins are placed in such a way no more than one coin ...


Q: Problem 3 Guessing game: For this program, have the user guess a number from 1-5. Next, generate a r...

A: Program instructions:Create a form with two fields and one submit button.User enters the number in a...


Q: An administrator has received a call indicating that some users are having difficulty logging on aft...

A: Domain Controller:Domain controller is a server computer on Microsoft servers.The purpose of domain ...


Q: I have the following code:   #include <iostream> #include <cstdlib>   using namespace st...

A: program to find that a number entered by the user is a Fibonacci number or not.This program executes...


Q: In MS Access, which character will be used for an optional digit such as 0, 1, 2, ..., 9? A) 0 B) 9 ...

A: Microsoft (MS) AccessMicrosoft access is a database management system from Microsoft that combines r...


Q: The following code I have written is supposed to check if the first character of the first given com...

A: Correction in the code- 1)Error in header file-    #include<string>   Rectified-   #include&lt...


Q: Draw the EER diagrams for the following problems using UML notation, Crow’s Foot notation and Chen n...

A: Hey, since there are multiple questions posted, we will answer first question. If you want any speci...