Analyze the code snippet below: package package1;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.net.MalformedURLException;import java.net.URL;public class WebPageTextReader {public static void main(String[] args) {try {URL url = new URL("http://eve.kean.edu/~ykumar/MyPage.html");// 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?
Analyze the code snippet below:
package package1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
public class WebPageTextReader {
public static void main(String[] args) {
try {
URL url = new URL("http://eve.kean.edu/~ykumar/MyPage.html");
// read text returned by server
BufferedReader in = new BufferedReader(new
InputStreamReader(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?

Trending now
This is a popular solution!
Step by step
Solved in 3 steps









