Advertisement
Shailrshah

Web Programming Question Bank Answers

Feb 17th, 2014
803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.69 KB | None | 0 0
  1. 1. Difference between GET and POST
  2. Ans. http://www.w3schools.com/tags/ref_httpmethods.asp
  3.  
  4. 2. A .css with background image, red background for table heading, Headings aligned to left, links not having underlines and paragraph having right & left margins of 100px.
  5. Ans. Here is style.css:-
  6. body{background-image:url('C:\Pictures\bg.jpeg');}
  7. th{background-color:#FF0000;}
  8. h1,h2,h3,h4,h5,h6{text-align:left;}
  9. a{text-decoration: none}
  10. p{margin-right:100px;margin-left:100px;}
  11.  
  12. 3. JavaScript build-in objects with description of its methods.
  13. Ans. An object is an unordered collection of properties, each of which has a name and a value
  14. i.Array: Used to store multiple values in one variable.
  15. Methods: concat(), indexOf(), lastIndexOf(), push(), pop(), sort(), etc.
  16. ii.Boolean: Used to convert a non-boolean value to a boolean.
  17. Methods: toString() and valueOf()
  18. iii.Date: To implement date and time.
  19. Methods: getDate(), getDay(), getFullYear(), getSeconds(), getMilliSeconds(), etc.
  20. iv.Math: For Mathematical methods.
  21. Methods: sin(), cos(), tan(), floor(), ceil(), log(), etc
  22. v.Number: Wrapper for primitive numbers
  23. Methods: toString(), valueOf(), toFixed(), toPrecision(), toExponential()
  24. vi.String: To store characters.
  25. Methods: charAt(), concat(), indexOf(), lastIndexOf(), split(), substring(), etc.
  26. vii.Regular Expression: To describe a pattern of characters.
  27. Methods: exec(), test() and toString()
  28.  
  29. 4. Explain URL.
  30. Ans. URL is Universal/Uniform Resource Locator. It's a unique path/address of a file that can be accessed through the internet. The file can be of any format-HTML, mp3 or an java applet. The URL contains the name of the protocol to be used to access the file resource, a domain name that identifies a specific computer on the Internet, and a pathname, a hierarchical description that specifies the location of a file in that computer.
  31. For Example: http://facebook.com/index.php
  32. Here, http is the name of the protocol(Hypertext Transfer Protocol), facebook.com is the domain name, and /index.php is the location & file name.
  33.  
  34. 5. Create a table with HTML tags
  35. Ans.
  36. <html>
  37. <head>
  38. <title>Table</title>
  39. </head>
  40. <body>
  41. <table border = "1" cellpadding = "5">
  42. <tr>
  43. <th rowspan ="2">Name of train</th>
  44. <th rowspan ="2">Place</th>
  45. <th rowspan ="2">Destination</th>
  46. <th colspan ="2">Time</th>
  47. <th rowspan ="2">Fare</th>
  48. </tr>
  49. <tr>
  50. <th>Departure</th>
  51. <th>Arrival</th>
  52. </tr>
  53. <tr>
  54. <td>Rajhdhani</td>
  55. <td>Mumbai</td>
  56. <td>Delhi</td>
  57. <td>07.30</td>
  58. <td>08.45</td>
  59. <td>Rs. 989.00</td>
  60. </tr>
  61. <tr>
  62. <td>Madras Mail</td>
  63. <td>Mumbai</td>
  64. <td>Madras</td>
  65. <td>09.00</td>
  66. <td>10.15</td>
  67. <td>Rs. 450.00</td>
  68. </tr>
  69. <tr>
  70. <td>Konark Exp</td>
  71. <td>Mumbai</td>
  72. <td>Manglore</td>
  73. <td>13.30</td>
  74. <td>14.45</td>
  75. <td>Rs. 756.00</td>
  76. </tr>
  77. <tr>
  78. <td>Deccan Exp</td>
  79. <td>Mumbai</td>
  80. <td>Pune</td>
  81. <td>16.00</td>
  82. <td>17.30</td>
  83. <td>Rs. 345.00</td>
  84. </tr>
  85. </table>
  86. </body>
  87. </html>
  88.  
  89. 6. Write a code in JavaScript to set a cookie.
  90. Ans.
  91. function setCookie(cName,cValue,exdays){
  92. var expires = "expires="+new Date().getTime();
  93. document.cookie = cName + "=" + cValue + "; " + expires;
  94. }
  95.  
  96. 7. Note on Web System Architecture
  97. Ans. http://blog.simcrest.com/what-is-3-tier-architecture-and-why-do-you-need-it/
  98.  
  99. 8.What's the need of style sheet? Explain different CSS with examples.
  100. Ans. A style sheet is a file that defines the visual layout of web pages. We need them because:-
  101. a. speed: Overall, users experience of a site utilizing style sheets will generally be quicker than sites that don’t use them. After the first page is loaded with the content and style sheet, the subsequent pages will load faster as the style sheet will be in the cache memory.
  102. b.Maintainability: Holding all the presentation styles in one file significantly reduces maintenance time and reduces the chance of human errors, thereby improving presentation consistency.
  103. c.Accessibility: Sites that use CSS with either XHTML or HTML are easier to tweak so that they appear extremely similar in different browsers.
  104. d.Customization: If a page's layout information is all stored externally, a user can decide to disable the layout information entirely, leaving the site's bare content still in a readable form. Site authors may also offer multiple style sheets, which can be used to completely change the appearance of the site without altering any of its content.
  105. e.Consistency: Because the semantic file contains only the meanings an author intends to convey, the styling of the various elements of the document's content is very consistent.
  106. f.Portability: The deferment of presentational details until the time of presentation means that a document can be easily re-purposed for an entirely different presentation medium with merely the application of a new style sheet already prepared for the new medium and consistent with elemental or structural vocabulary of the semantic document.
  107.  
  108. The different ways to implement CSS are:-
  109. a.External:An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section. Eg:-
  110. <head>
  111. <link rel="stylesheet" type="text/css" href="style.css">
  112. </head>
  113. b.Internal:You define internal styles in the head section of an HTML page, by using the <style> tag. Eg:-
  114. <head>
  115. <style>
  116. p {margin-left:10px;}
  117. </style>
  118. </head>
  119. c.Inline:To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. Eg: <p style="margin-left:10px;">
  120.  
  121. 9. Write a java code to:-
  122. a. display digital clock on screen.
  123. Ans.
  124. <html>
  125. <head>
  126. <script type = "text/javascript">
  127. function getTime(){
  128. setTimeout("getTime()", 1000);
  129. document.getElementById('time').innerHTML=new Date().toLocaleTimeString();
  130. }
  131. getTime();
  132. </script>
  133. </head>
  134. <body>
  135. <h4>Current Time: <span id="time" /></h4>
  136. </body>
  137. </html>
  138. b. change image ads automatically after 5 seconds
  139. Ans.
  140. <html>
  141. <head>
  142. <script type="text/javascript">
  143. var image1 = new Image()
  144. image1.src = "a.jpg"
  145. var image2 = new Image()
  146. image2.src = "b.jpg"
  147. </script>
  148. </head>
  149. <body>
  150. <img src="a.jpg" width="500" height="300" name="change" />
  151. <script type="text/javascript">
  152. var step=1;
  153. function changeImg()
  154. {
  155. document.images.change.src = eval("image"+step+".src");
  156. if(step<2)
  157. step++;
  158. else
  159. step=1;
  160. setTimeout("changeImg()",5000);
  161. }
  162. changeImg();
  163. </script>
  164. </body>
  165. </html>
  166.  
  167. 10.Explain DNS.
  168. Ans. http://computer.howstuffworks.com/dns.htm
  169.  
  170. 11.Explain DOM with example
  171. Ans. http://www.w3schools.com/js/js_htmldom.asp
  172.  
  173. 12.List and explain elements for getting user input in HTML.
  174. Ans. http://www.w3schools.com/html/html_forms.asp
  175.  
  176. 13. Make a resume in HTML.
  177. Ans. Trick question. Resumes are made in Microsoft Word.
  178.  
  179. 14. Write code to validate a form.
  180. Ans.
  181. <html>
  182. <head>
  183. <script>
  184. function validateForm(){
  185. var fname=document.forms["myForm"]["fname"].value;
  186. var age=parseInt(document.forms["myForm"]["age"].value);
  187. var address=document.forms["myForm"]["address"].value;
  188. var gender=document.forms["myForm"]["gender"].value;
  189. var state=document.forms["myForm"]["state"].value;
  190. if (fname==null || fname==""){
  191. alert("First name must be filled out");
  192. return false;
  193. }
  194. if(age<0||age>100||isNaN(age)) {
  195. alert("age has to be a positive number");
  196. return false;
  197. }
  198. if (address==null || address==""){
  199. alert("Please enter your address.");
  200. return false;
  201. }
  202. if (gender==""){
  203. alert("Please select your gender.");
  204. return false;
  205. }
  206. if (state==null || state==""){
  207. alert("Please enter your state");
  208. return false;
  209. }
  210. }
  211. </script>
  212. </head>
  213. <body>
  214. <form name="myForm" onsubmit="return validateForm()" method="post">
  215. First name: <input type="text" name="fname"><br>
  216. Age: <input type="text" name ="age"><br>
  217. Gender:<select name ="gender">
  218. <option></option>
  219. <option>male</option>
  220. <option>female</option>
  221. </select><br>
  222. Address: <textarea rows="4" cols="50" name="address"></textarea><br>
  223. State:<input type="text" name="state"><br>
  224. <input type="submit" value="Submit">
  225. </form>
  226. </body>
  227. </html>
  228.  
  229. 15. Explain 3-tier architechture.
  230. Ans.Three-tier or multi-tier architecture are often used when describing how clients connect to servers. It consists of 3 layers:-
  231. a. Client Tier consists of client computers. This tier handles the presentation logic.
  232. b. Business Logic Tier consists of business logic servers. This tier handles the bussiness logic.
  233. c. Database Tier consists of database servers. This tier handles the back-end data.
  234. The advantages are:-
  235. a.Good security
  236. b. Faster execution
  237. c. very scalable
  238. The disadvantages are:-
  239. a. More expensive
  240. b. More complex
  241.  
  242. 16. Write an HTML file which has a drop down menu containing colors. On selecting an option, the background color should change to the color selected.
  243. Ans.
  244. <html>
  245. <head>
  246. <script>
  247. function changeBackground(){
  248. document.body.style.backgroundColor= document.getElementById("colors").value;
  249. }
  250. </script>
  251. </head>
  252.  
  253. <body>
  254. <form>
  255. <select id="colors" onchange="changeBackground()">
  256. <option>white</option>
  257. <option>red</option>
  258. <option>green</option>
  259. <option>blue</option>
  260. <option>grey</option>
  261. </select>
  262. </form>
  263. </body>
  264. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement