-
What is the output of this program?
import java.net.*;
public class networking_Example
{
public static void main(String[] args) throws UnknownHostException
{
InetAddress object1 = InetAddress.getByName("tcs.com");
InetAddress object2 = InetAddress.getByName("interviewmania.com");
boolean p = object1.equals(object2);
System.out.print(p);
}
}
-
- 1
- 0
- true
- false
- None of these
Correct Option: D
InetAddress object1 = InetAddress.getByName(“tcs.com”); creates object object1 having DNS and IP address of tcs.com, InetAddress object2 = InetAddress.getByName(“interviewmania.com”); creates object2 having DNS and IP address of interviewmania.com , since both these address point to two different locations false is returned by object1.equals(object2);.