Networking:
How many ports of TCP/IP are reserved for specific protocols?
1024
Which of these exception is thrown by URL class’s constructors?
MalformedURLException
Which of these methods is used to know the full URL of an URL object?
toExternalForm()
What is the output of this program?
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getPort());
Ans. -1
Which of these method of DatagramPacket is used to find the port number?
port()
Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram?
getData()
Which of these method of DatagramPacket is used to find the length of byte array?
getLength()
Which of these data member of HttpResponse class is used to store the response from a http server?
statusCode
What is the output of this program?
URL obj = new URL("http://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getLastModified);
Host URL was last modified on june 18 tuesday 2013 .
Ans. Tue Jun 18 2013
Which of these interface abstractes the output of messages from httpd?
a) LogMessage
Which of these methods is used to make raw MIME formatted string?
a) parse()
Multithreading:
What is the output of this program?
obj1.t.wait();
System.out.print(obj1.t.isAlive());
obj1.t.wait() causes main thread to go out of processing in sleep state hence causes exception and “Main thread interrupted” is printed.
Thread.sleep(1000) has caused all the threads to be suspended for some time,
What is the output of this program?
Thread t = Thread.currentThread();
System.out.println(t);
Thread[main,5,main]
Thread t has been made by using Runnable interface, hence it is necessary to use inherited abstract method run() method to specify instructions to be implemented on the thread, since no run() method is used it gives a compilation error.
Collections:
when method Arrays.fill(array, 1, 4, 8) is called it fills the index location starting with 1 to 4 by value 8
Which of these interface handle sequences?
Set List Comparator Collection
List
Which of these methods can randomize all elements in a list?
shuffle()
Which of these methods can convert an object into a List?
singletonList()
Which of these methods is used to obtain an iterator to the start of collection?
iterator()
Which of these exceptions is thrown by remover() method?
IllegalStateException
Which of these data type cannot be type parameterized?
a) Array
Which of the following cannot be Type parameterized?
a) Oveloaded Methods
Which of these method of ArrayList class is used to obtain present size of an object?
a) size()
Although obj.ensureCapacity(3); has manually increased the capacity of obj to 3 but the value is stored only at index 0, therefore obj.size() returns the total number of elements stored in the obj i:e 1, it has nothing to do with ensureCapacity()
Which of these method is used to add an element to the start of a LinkedList object?
addFirst()
Which of these method of HashSet class is used to add elements to its object?
a) add()
Which of these method Map class is used to obtain an element in the map having specified key?
a) search()
Which of these method is used add an element and corresponding key to a map?
a) put()
How many ports of TCP/IP are reserved for specific protocols?
1024
Which of these exception is thrown by URL class’s constructors?
MalformedURLException
Which of these methods is used to know the full URL of an URL object?
toExternalForm()
What is the output of this program?
URL obj = new URL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getPort());
Ans. -1
Which of these method of DatagramPacket is used to find the port number?
port()
Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram?
getData()
Which of these method of DatagramPacket is used to find the length of byte array?
getLength()
Which of these data member of HttpResponse class is used to store the response from a http server?
statusCode
What is the output of this program?
URL obj = new URL("http://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getLastModified);
Host URL was last modified on june 18 tuesday 2013 .
Ans. Tue Jun 18 2013
Which of these interface abstractes the output of messages from httpd?
a) LogMessage
Which of these methods is used to make raw MIME formatted string?
a) parse()
Multithreading:
What is the output of this program?
obj1.t.wait();
System.out.print(obj1.t.isAlive());
obj1.t.wait() causes main thread to go out of processing in sleep state hence causes exception and “Main thread interrupted” is printed.
Thread.sleep(1000) has caused all the threads to be suspended for some time,
What is the output of this program?
Thread t = Thread.currentThread();
System.out.println(t);
Thread[main,5,main]
Thread t has been made by using Runnable interface, hence it is necessary to use inherited abstract method run() method to specify instructions to be implemented on the thread, since no run() method is used it gives a compilation error.
Collections:
when method Arrays.fill(array, 1, 4, 8) is called it fills the index location starting with 1 to 4 by value 8
Which of these interface handle sequences?
Set List Comparator Collection
List
Which of these methods can randomize all elements in a list?
shuffle()
Which of these methods can convert an object into a List?
singletonList()
Which of these methods is used to obtain an iterator to the start of collection?
iterator()
Which of these exceptions is thrown by remover() method?
IllegalStateException
Which of these data type cannot be type parameterized?
a) Array
Which of the following cannot be Type parameterized?
a) Oveloaded Methods
Which of these method of ArrayList class is used to obtain present size of an object?
a) size()
Although obj.ensureCapacity(3); has manually increased the capacity of obj to 3 but the value is stored only at index 0, therefore obj.size() returns the total number of elements stored in the obj i:e 1, it has nothing to do with ensureCapacity()
Which of these method is used to add an element to the start of a LinkedList object?
addFirst()
Which of these method of HashSet class is used to add elements to its object?
a) add()
Which of these method Map class is used to obtain an element in the map having specified key?
a) search()
Which of these method is used add an element and corresponding key to a map?
a) put()
No comments:
Post a Comment