Loading...

Sample Questions-4

Q. 1. What are the different data types present in javascript?
Ans. JavaScript data types are 1. Primitive types a. String - It represents a series of characters and is written with quotes. A string can be represented using a single or a double quote. Example : var str = "Vivek Singh Bisht"; //using double quotes var str2 = 'John Doe'; //using single quotes b. Number - It represents a number and can be written with or without decimals. Example : var x = 3; //without decimal var y = 3.6; //with decimal c. BigInt - This data type is used to store numbers which are above the limitation of the Number data type. It can store large integers and is represented by adding “n” to an integer literal. Example : var bigInteger = 234567890123456789012345678901234567890; d. Boolean - It represents a logical entity and can have only two values : true or false. Booleans are generally used for conditional testing. Example : true and false e. Undefined - When a variable is declared but not assigned, it has the value of undefined and it’s type is also undefined. Example : var x; // value of x is undefined var y = undefined; // we can also set the value of a variable as undefined f. Null - It represents a non-existent or a invalid value. Example : var z = null; g. Symbol - It is a new data type introduced in the ES6 version of javascript. It is used to store an anonymous and unique value. Example : var symbol1 = Symbol('symbol'); 2. Non-primitive types Primitive data types can store only a single value. To store multiple and complex values, non-primitive data types are used. a. Object - Used to store collection of data. Example: // Collection of data in key-value pairs var obj1 = { x: 43, y: "Hello world!", z: function(){ return this.x; } } b. Array It represents a collection of similar elements in JavaScript. c. RegExp

Q. 2. Difference between “ == “ and “ === “ operators?
Ans. Both are comparison operators. The difference between both the operators is that “==” is used to compare values whereas, “ === “ is used to compare both values and types.

Q. 3. What is Javascript? write Features of javascript?

Q. 4. Describe History of Javascript? What is the application of javascript?

Q. 5. Write where we can put javascript code in html

Q. 6. How can we use external javascript? Give example.

Q. 7. What is comment in html, css and javascript? Describe Single line and multiline comments in html, css and javascript.

Q. 8. What is Javascript variables? Write rules for declaring variables.

Q. 9. What are the extension for html, css and javascript files?

Q. 10. Give definition and example of javascript operators.

Q. 11. What is internal css? Give definition and examples.

Q. 12. What is the difference between inline css and external css? give examples

Q. 13. What are the advantages of using CSS? What are the limitations of CSS?
Ans. The main advantages of CSS are given below: Separation of content from presentation - CSS provides a way to present the same content in multiple presentation formats in mobile or desktop or laptop. Easy to maintain - CSS, built effectively can be used to change the look and feel complete by making small changes. To make a global change, simply change the style, and all elements in all the web pages will be updated automatically. Bandwidth - Used effectively, the style sheets will be stored in the browser cache and they can be used on multiple pages, without having to download again. Disadvantages of CSS are given below: Browser Compatibility: Some style selectors are supported and some are not. We have to determine which style is supported or not using the @support selector). Cross Browser issue: Some selectors behave differently in a different browser). There is no parent selector: Currently, Using CSS, you can’t select a parent tag.

Q. 14. How to include CSS in the webpage?
Ans. There are different ways to include a CSS in a webpage, 1 - External Style Sheet: An external file linked to your HTML document: Using link tag, we can link the style sheet to the HTML page. < link rel="stylesheet" type="text/css" href="mystyles.css" /> 2 - Embed CSS with a style tag: A set of CSS styles included within your HTML page. < style type="text/css"> /*Add style rules here*/ Add your CSS rules between the opening and closing style tags and write your CSS exactly the same way as you do in stand-alone stylesheet files. 3 - Add inline styles to HTML elements(CSS rules applied directly within an HTML tag.): Style can be added directly to the HTML element using a style tag. < h2 style="color:red;background:black">Inline Style


Q. 15. What is the syntax for CSS?
Ans. A CSS style rule consists of a selector, property, and its value. The selector points to the HTML element where CSS style is to be applied. The CSS property is separated by semicolons. Syntax: selector { Property: value; }