What will be the output of the following Java program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("https://www.example.com/javamcq");
URLConnection obj1 = obj.openConnection();
int len = obj1.getContentLength();
System.out.print(len);
}
}
Note: Host URL is having length of content 127.
Select an option to see the answer and solution.
Which of these method of MimeHeader is used to return the string equivalent of the values stores on MimeHeader?
Select an option to see the answer and solution.
Which of these is an instance variable of class httpd?
Select an option to see the answer and solution.
Which of these exceptions is thrown by URL class's constructors?
Select an option to see the answer and solution.
What will be the output of the following Java program?
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException
{
URL obj = new URL("https://www.example.com/javamcq");
System.out.print(obj.getHost());
}
}
Select an option to see the answer and solution.
Which of these class must be used to send a datagram packets over a connection?
Select an option to see the answer and solution.
Which of these process occur automatically by the java runtime system?
Select an option to see the answer and solution.
What will be the output of the following Java program?
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException
{
URL obj = new URL("https://www.example.com/javamcq");
System.out.print(obj.toExternalForm());
}
}
Select an option to see the answer and solution.
Which of these methods of DatagramPacket is used to find the length of byte array?
Select an option to see the answer and solution.
Which of these is a bundle of information passed between machines?
Select an option to see the answer and solution.
Which of these is method of ObjectOutput interface used to write the object to input or output stream as required?
Select an option to see the answer and solution.
What will be the output of the following Java program?
import java.io.*;
class streams
{
public static void main(String[] args)
{
try
{
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeFloat(3.5);
oos.flush();
oos.close();
}
catch(Exception e)
{
System.out.println("Serialization" + e);
System.exit(0);
}
try
{
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
ois.close();
System.out.println(ois.available());
}
catch (Exception e)
{
System.out.print("deserialization");
System.exit(0);
}
}
}
Select an option to see the answer and solution.
Which of these methods of httpd class is used to read data from the stream?
Select an option to see the answer and solution.
Which of these package contains classes and interfaces for networking?
Select an option to see the answer and solution.
What will be the output of the following Java program?
import java.io.FileOutputStream;
public class FileOutputStreamExample
{
public static void main(String args[])
{
try
{
FileOutputStream fout=new FileOutputStream("D:\\example.txt");
String s="Welcome to India.";
byte b[]=s.getBytes();//converting string into byte array
fout.write(b);
fout.close();
System.out.println("Success");
} catch(Exception e){System.out.println(e);}
}
}
Select an option to see the answer and solution.
What will be the output of the following Java program?
import java.io.*;
class serialization
{
public static void main(String[] args)
{
try
{
Myclass object1 = new Myclass("Hello", -7, 2.1e10);
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(object1);
oos.flush();
oos.close();
}
catch(Exception e)
{
System.out.println("Serialization" + e);
System.exit(0);
}
try
{
Myclass object2;
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
object2 = (Myclass)ois.readObject();
ois.close();
System.out.println(object2);
}
catch (Exception e)
{
System.out.print("deserialization" + e);
System.exit(0);
}
}
}
class Myclass implements Serializable
{
String s;
int i;
double d;
Myclass (String s, int i, double d)
{
this.d = d;
this.i = i;
this.s = s;
}
}
Select an option to see the answer and solution.
If member does not implement serialization, which exception would be thrown?
Select an option to see the answer and solution.
How many bits are in a single IP address?
Select an option to see the answer and solution.
Which of these transfer protocol must be used so that URL can be accessed by URLConnection class object?
Select an option to see the answer and solution.
What will be the output of the following Java code?
import java.net.*;
class networking
{
public static void main(String[] args) throws MalformedURLException
{
URL obj = new URL("https://www.example.com/javamcq");
System.out.print(obj.getProtocol());
}
}
Select an option to see the answer and solution.