This section of our 1000+ C# MCQs focuses on Url class in C# Programming Language.
1. What does URL stand for?
a) Uniform Resource Locator
b) Uniform Resource Latch
c) Universal Resource Locator
d) Universal Resource Latch
2. Which of these exceptions is thrown by the URL class’s constructors?
a) URLNotFound
b) URLSourceNotFound
c) MalformedURLException
d) URLNotFoundException
3. What does the following form define?
Protocol://HostName/FilePath?Query
a) Protocol specifies the protocol being used, such as HTTP
b) HostName identifies a specific server, such as mhprofessional.com or www.google.com
c) FilePath specifies the path to a specific file
d) All of the mentioned
4. Which of these classes is used to encapsulate IP address and DNS?
a) DatagramPacket
b) URL
c) InetAddress
d) ContentHandler
5. Which of these is a standard for communicating multimedia content over email?
a) http
b) https
c) Mime
d) httpd
6. What does the following method specify?
public static WebRequest Create(string requestUriString)
a) Creates a WebRequest object for the URI specified by the string passed by requestUriString
b) The object returned will implement the protocol specified by the prefix of the URI
c) The object will be an instance of the class that inherits WebRequest
d) All of the mentioned
7. What will be the output of the following C# code?
class Program
{
static void Main(string[] args)
{
int ch;
HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://www.McGraw-Hill.com");
HttpWebResponse resp = (HttpWebResponse) req.GetResponse();
Stream istrm = resp.GetResponseStream();
for (int i = 1 ; ;i++)
{
ch = istrm.ReadByte();
if (ch == -1)
break;
Console.Write((char)ch);
if ((i % 400) == 0)
{
Console.Write("\nPress Enter.");
Console.ReadLine();
}
}
resp.Close();
}
}
a) html
b) text
c) html/text
d) text/html
8. What will be the output of the following C# code?
class Program
{
static void Main(string[] args)
{
Uri obj = new Uri("https://www.sanfoundry.com/csharpmcq");
Console.WriteLine(obj.AbsoluteUri);
Console.ReadLine();
}
}
a) sanfoundry
b) sanfoundry.com
c) www.sanfoundry.com
d) https://www.sanfoundry.com/csharpmcq
https://www.sanfoundry.com/csharpmcq
9. Which of these data members of HttpResponse class is used to store the response from a http server?
a) status
b) address
c) statusResponse
d) statusCode
10. Which of these classes is used to access actual bits or content information of a URL?
a) URL
b) URLDecoder
c) URLConnection
d) All of the mentioned