12 To 15
12 To 15
3
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
// Constructor
Exp() {
setSize(350, 350);
setVisible(true);
setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20)); // Corrected layout initialization
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
// Main method
public static void main(String[] args) {
Exp t = new Exp(); // Corrected constructor name
t.setTitle("Manthan");
}
}
13.1
import java.awt.*;
import java.awt.event.*;
public InetAddressDemo() {
setTitle("Manthan "); // Set the title of the window
setSize(400, 150);
setDefaultCloseOperation(EXIT_ON_CLOSE); // Exit on close
// Create components
hostnameField = new JTextField(20);
JButton lookupButton = new JButton("Lookup IP");
resultLabel = new JLabel("Enter hostname and click 'Lookup IP'", SwingConstants.CENTER);
import java.net.*;
class URLdemo
{
public static void main(String[] args) throws Exception{
System.out.println("Manthan ");
URL url=new
URL("https://www.geeksforgeeks.org/what-is-url-uniform-resource-locator/");
System.out.println(url.getProtocol());
System.out.println(url.getHost());
System.out.println(url.getPort());
System.out.println(url.getFile());
}
}
15.2