Q. Write a Java progarm in order to check the IP Address of the system.
Ans.
import java.io.*;
import java.net.*;
public class ip
{
public static void main(String args[])
{
try
{
InetAddress ob=InetAddress.getLocalHost();
System.out.println("IP of my system:"+ob.getHostAddress());
}
catch(IOException e)
{
System.out.println("Exception is="+e.getMessage()e.getMessage());
}
}
}
Output:
javac ip.java (//enter)
java ip (//enter)
IP of my system: 192.168.1.21
ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix: domain.name
IP Address............................: 192.168.1.21
Subnet Musk.........................: 255.255.255.0
Default Gateway....................: 192.168.1.1
Free image Downloaded from unsplash.com |
0 Comments