Upwork MySQL Test latest

MySQL Test 2017

1. Which of the following are true in case of Indexes for MYISAM Tables?

Answers:

  1. Indexes can have NULL values
  2. BLOB and TEXT columns can be indexed
  3. Indexes per table cannot be more than 16
  4. Columns per index cannot be more than 16

2. Below is the table “messages,” please find proper query and result from the choices below.

Id Name Other_Columns
————————-
1 A A_data_1
2 A A_data_2
3 A A_data_3
4 B B_data_1
5 B B_data_2
6 C C_data_1

Answers:

  1. select * from (select * from messages GROUP BY id DESC) AS x ORDER BY name Result: 3 A A_data_3 5 B B_data_2 6 C C_data_1
  2. select * from messages where name =Desc Result: 1 A A_data_1 2 A A_data_2 3 A A_data_3
  3. select * from messages group by name Result: 1 A A_data_1 4 B B_data_1 6 C C_data_1
  4. Answer A and B

3. How can an user quickly rename a MySQL database for InnoDB?

Answers:

  1. He cannot rename any MySQL database
  2. By using: RENAME DATABASE db_old_name TO db_new_name
  3. By using: RENAME DATABASE TO db_new_name
  4. By creating the new empty database, then rename each table using: RENAME TABLE db_old_name.table_name TO db_new_name.table_name

4. Is it possible to insert several rows into a table with a single INSERT statement?

Answers:

  1. No
  2. Yes

5. Consider the following tables:

books

——

bookid

bookname

authorid

subjectid

popularityrating (the popularity of the book on a scale of 1 to 10)

language (such as French, English, German etc)

Subjects

———

subjectid

subject (such as History, Geography, Mathematics etc)

authors

——–

authorid

authorname

country
Which is the query to determine the Authors who have written at least 1 book with a popularity rating of less than 5?

Answers:

  1. select authorname from authors where authorid in (select authorid from books where popularityrating<5)
  2. select authorname from authors where authorid in (select authorid from books where popularityrating<=5)
  3. select authorname from authors where authorid in (select bookid from books where popularityrating<5)
  4. select authorname from authors where authorid in (select authorid from books where popularityrating in (0,5))

6. The Flush statement cannot be used for:

Answers:

  1. Closing any open tables in the table cache
  2. Closing open connections
  3. Flushing the log file
  4. Flushing the host cache

7. Consider the query:

SELECT name

FROM Students

WHERE name LIKE ‘_a%’;
Which names will be displayed?

Answers:

  1. Names starting with “a”
  2. Names containing “a” as the second lette
  3. Names starting with “a” or “A”
  4. Names containing “a” as any letter except the first

8. Which of the following is the best MySQL data type for currency values?

Answers:

  1. SMALLINT
  2. DECIMAL(19,4)
  3. VARCHAR(32)
  4. BIGINT

9. What are MySQL Spatial Data Types in the following list?

Answers:

  1. GEOMETRY
  2. CIRCLE
  3. SQUARE
  4. POINT
  5. POLYGON

10. Examine the two SQL statements given below:

SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC

SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC

What is true about them?

Answers:

  1. The two statements produce identical results
  2. The second statement returns an error
  3. There is no need to specify DESC because the results are sorted in descending order by default
  4. None of the above statments is correct

11. Which of the following will raise MySQL’s version of an error?

Answers:

  1. SIGNAL
  2. RAISE
  3. ERROR
  4. None of these.

12. Which query will return values containing strings “Pizza”, “Burger”, or “Hotdog” in the database?

Answers:

  1. SELECT * FROM fiberbox WHERE field REGEXP ‘Pizza|Burger|Hotdog’;
  2. SELECT * FROM fiberbox WHERE field LIKE ‘%Pizza%’ OR field LIKE ‘%Burger%’ OR field LIKE ‘%Hotdog%’;
  3. SELECT * FROM fiberbox WHERE field = ‘%Pizza%’ OR field = ‘%Burger%’ OR field = ‘%Hotdog%’;
  4. SELECT * FROM fiberbox WHERE field = ‘?Pizza?’ OR field = ‘?Burger?’ OR field = ‘?Hotdog?’;

13. Which datatype is used to store binary data in MySQL?

Answers:

  1. BLOB
  2. BIGINT
  3. INT
  4. Both BLOB and BIGINT

14. Which of the following will reset the MySQL password for a particular user?

Answers:

  1. UPDATE mysql.user SET Password=PASSWORD(‘password’) WHERE User=’username’;
  2. UPDATE mysql.user SET Password=’password’ WHERE User=’username’;
  3. UPDATE mysql.user SET Password=RESET(‘password’) WHERE User=’username’;
  4. None of the above.

15. Which of the following is the best way to modify a table to allow null values?

Answers:

  1. ALTER TABLE table_name MODIFY column_name varchar(255) null
  2. ALTER TABLE table_name MODIFY column_name VARCHAR(255)
  3. ALTER TABLE table_name CHANGE column_name column_name type DEFAULT NULL
  4. ALTER table_name MODIFY column_name varchar(255) null

16. Which of the following will dump the whole MySQL database to a file?

Answers:

  1. mysql -e “select * from myTable” -u myuser -pxxxxxxxxx mydatabase > mydumpfile.txt
  2. mysql -e “select * from myTable” mydatabase > mydumpfile.txt
  3. SELECT * from myTable FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘n’
  4. None of the above.

17. Which of the following statements is true regarding character sets in MySQL?

Answers:

  1. The default character set of MySQL is UTF-8.
  2. lang.cnf sets the default character set for MySQL databases.
  3. SET CHARSET utf8 will set the character set of data to be imported to UTF-8.
  4. None of these.

18. Which of the following is an alternative to groupwise maximum ranking (ex. ROW_NUMBER() in MS SQL)?

Answers:

  1. Using subqueries
  2. Using variables in a MySQL query
  3. Using self-join
  4. MySQL also supports ROW_NUMBER()

19. Consider the following tables:

Books
——
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)

Subjects
———
SubjectId
Subject (such as History, Geography, Mathematics etc)

Authors
——–
AuthorId
AuthorName
Country

Which query will determine how many books have a popularity rating of more than 7 on each subject?

Answers:

  1. select subject,count(*) as Books from books,subjects where books.popularityrating > 7
  2. select subject,count(*) as Books from books,subjects where books.authorid=subjects.authorid and books.popularityrating > 7 group by subjects.subject
  3. select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating = 7 group by subjects.subject
  4. select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating > 7 group by subjects.subject

20. Which of the following statements are true about SQL injection attacks?

Answers:

  1. Wrapping all variables containing user input by a call to mysql_real_escape_string() makes the code immune to SQL injections.
  2. Parametrized queries do not make code less vulnearable to SQL injections.
  3. SQL injections are not possible, if only emulated prepared statements are used.
  4. Usage of later versions of MySQL, validation, and explicit setting of the charset of user input are valid measures to decrease vulnerability to SQL injections.

21. Which of the following is an alternative to Subquery Factoring (ex. the ‘WITH’ clause in MS SQL Server)?

Answers:

  1. The ‘IN’ clause
  2. Using temporary tables and inline views
  3. The ‘INNER JOIN’ clause
  4. Using subqueries

22. Suppose a table has the following records:

+————–+————-+—————-+
| Item | Price | Brand |
+————–+————-+—————-+
| Watch | 100 | abc |
| Watch | 200 | xyz |
| Glasses | 300 | bcd |
| Watch | 500 | def |
| Glasses | 600 | fgh |
+————–+————-+—————-+

Which of the following will select the highest-priced record per item?

Answers:

  1. select item, brand, price from items where max(price) order by item
  2. select * from items where price = max group by item
  3. select item, brand, max(price) from items group by item
  4. select * from items where price > 200 order by item

23. Which of the following will restore a MySQL DB from a .dump file?

Answers:

  1. mysql -u<user> -p < db_backup.dump
  2. mysql -u<user> -p<password> < db_backup.dump
  3. mysql -u<user> -p <password> < db_backup.dump
  4. mysql -u<user> -p<password> > db_backup.dump

24. Which of the following will show when a table in a MySQL database was last updated?

Answers:

  1. Using the following query: SELECT UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA = ‘database_name’ AND TABLE_NAME = ‘table_name’
  2. Creating an on-update trigger to write timestamp in a custom table, then querying the custom table
  3. Getting the “last modified” timestamp of the corresponding database file in the file system
  4. None of these.

25. Which of the following results in 0 (false)?

Answers:

  1. “EXPERTRATING” LIKE “EXP%”
  2. “EXPERTRATING” LIKE “Exp%”
  3. BINARY “EXPERTRATING” LIKE “EXP%”
  4. BINARY “EXPERTRATING” LIKE “Exp%”
  5. All will result in 1 (true)

26. Which of the following relational database management systems is simple to embed in a larger program?

Answers:

  1. MySQL
  2. SQLite
  3. Both
  4. None

27. What is true about the ENUM data type?

Answers:

  1. An enum value may be a user variable
  2. An enum may contain number enclosed in quotes
  3. An enum cannot contain an empty string
  4. An enum value may be NULL
  5. None of the above is true

28. What will happen if two tables in a database are named rating and RATING?

Answers:

  1. This is not possible as table names are case in-sensitive (rating and RATING are treated as same name)
  2. This is possible as table names are case sensitive (rating and RATING are treated as different names)
  3. This is possible on UNIX/LINUX and not on Windows platform
  4. This is possible on Windows and not on UNIX/LINUX platforms
  5. This depends on lower_case_table_names system variable

29. How can a InnoDB database be backed up without locking the tables?

Answers:

  1. mysqldump –single-transaction db_name
  2. mysqldump –force db_name
  3. mysqldump –quick db_name
  4. mysqldump –no-tablespaces db_name

30. What does the term “overhead” mean in MySQL?

Answers:

  1. Temporary diskspace that the database uses to run some of the queries
  2. The size of a table
  3. A tablespace name
  4. None of the above

31. Consider the following select statement and its output:

SELECT * FROM table1 ORDER BY column1;
Column1

——–

1

2

2

2

2

2

3
Given the above output, which one of the following commands deletes 3 of the 5 rows where column1 equals 2?

Answers:

  1. DELETE FIRST 4 FROM table1 WHERE column1=2
  2. DELETE 4 FROM table1 WHERE column1=2
  3. DELETE WHERE column1=2 LIMIT 4
  4. DELETE FROM table1 WHERE column1=2 LIMIT 3
  5. DELETE FROM table1 WHERE column1=2 LEAVING 1

32. Consider the following queries:

create table foo (id int primary key auto_increment, name int);
create table foo2 (id int auto_increment primary key, foo_id int references foo(id) on delete cascade);

Which of the following statements is true?

Answers:

  1. Two tables are created
  2. If a row in table foo2, with a foo_id of 2 is deleted, then the row with id = 2 in table foo is automatically deleted
  3. Those queries are invalid
  4. If a row with id = 2 in table foo is deleted, all rows with foo_id = 2 in table foo2 are deleted

33. What is NDB?

Answers:

  1. An in-memory storage engine offering high-availability and data-persistence features
  2. A filesystem
  3. An SQL superset
  4. MySQL scripting language
  5. None of the above

34. Which of the following statements are true?

Answers:

  1. Names of databases, tables and columns can be up to 64 characters in length
  2. Alias names can be up to 255 characters in length
  3. Names of databases, tables and columns can be up to 256 characters in length
  4. Alias names can be up to 64 characters in length

35. Which of the following statements is used to change the structure of a table once it has been created?

Answers:

  1. CHANGE TABLE
  2. MODIFY TABLE
  3. ALTER TABLE
  4. UPDATE TABLE

36. What does DETERMINISTIC mean in the creation of a function?

Answers:

  1. The function returns no value
  2. The function always returns the same value for the same input
  3. The function returns the input value
  4. None of the above

37. Which of the following statements grants permission to Peter with password Software?

Answers:

  1. GRANT ALL ON testdb.* TO peter PASSWORD ‘Software’
  2. GRANT ALL ON testdb.* TO peter IDENTIFIED by ‘Software’
  3. GRANT ALL OF testdb.* TO peter PASSWORD ‘Software’
  4. GRANT ALL OF testdb.* TO peter IDENTIFIED by ‘Software’

38. What will happen if you query the emp table as shown below:

select empno, DISTINCT ename, Salary from emp;

Answers:

  1. EMPNO, unique value of ENAME and then SALARY are displayed
  2. EMPNO, unique value ENAME and unique value of SALARY are displayed
  3. DISTINCT is not a valid keyword in SQL
  4. No values will be displayed because the statement will return an error

39. Which of the following is the best way to disable caching for a query?

Answers:

  1. Add the /*!no_query_cache*/ comment to the query.
  2. Flush the whole cache with the command: FLUSH QUERY CACHE
  3. Reset the query cache with the command: RESET QUERY CACHE
  4. Use the SQL_NO_CACHE option in the query.

40. What is the maximum size of a row in a MyISAM table?

Answers:

  1. No limit
  2. OS specific
  3. 65,534
  4. 2’147’483’648
  5. 128

41. Can you run multiple MySQL servers on a single machine?

Answers:

  1. No
  2. Yes

42. Which of the following formats does the date field accept by default?

Answers:

  1. DD-MM-YYYY
  2. YYYY-DD-MM
  3. YYYY-MM-DD
  4. MM-DD-YY
  5. MMDDYYYY

43. State whether true or false:
In the ‘where clause’ of a select statement, the AND operator displays a row if any of the conditions listed are true. The OR operator displays a row if all of the conditions listed are true.

Answers:

  1. True
  2. False

44. What is the name of the utility used to extract NDB configuration information?

Answers:

  1. ndb_config
  2. cluster_config
  3. ndb –config
  4. configNd
  5. None of the above

45. Which one of the following must be specified in every DELETE statement?

Answers:

  1. Table Name
  2. Database name
  3. LIMIT clause
  4. WHERE clause

46. Which of the following are not Numeric column types?

Answers:

  1. BIGINT
  2. LARGEINT
  3. SMALLINT
  4. DOUBLE
  5. DECIMAL

47. Which of the following statements is true regarding multi-table querying in MySQL?

Answers:

  1. JOIN queries are faster than WHERE queries.
  2. WHERE queries are faster than JOIN queries.
  3. INNER queries are faster than JOIN queries.
  4. WHERE & INNER offer the same performance in terms of speed.

48. What is wrong with the following statement?

create table foo (id int auto_increment, name int);

Answers:

  1. Nothing
  2. The id column cannot be auto incremented because it has not been defined as a primary key
  3. It is not spelled correctly. It should be: CREATE TABLE foo (id int AUTO_INCREMENT, name int);

49. Consider the following table definition:

CREATE TABLE table1 (
column1 INT,
column2 INT,
column3 INT,
column4 INT
)

Which one of the following is the correct syntax for adding the column, “column2a” after column2, to the table shown above?

Answers:

  1. ALTER TABLE table1 ADD column2a INT AFTER column2
  2. MODIFY TABLE table1 ADD column2a AFTER column2
  3. INSERT INTO table1 column2a AS INT AFTER column2
  4. ALTER TABLE table1 INSERT column2a INT AFTER column2
  5. CHANGE TABLE table1 INSERT column2a BEFORE column3
  6. Columns are always added after the last column

50. Examine the data in the employees table given below:
last_name department_id salary

ALLEN 10 3000

MILLER 20 1500

King 20 2200

Davis 30 5000
Which of the following Subqueries will execute well?

Answers:

  1. SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id);
  2. SELECT * FROM employees WHERE salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
  3. SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
  4. SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
  5. SELECT department_id FROM employees WHERE salary > ALL (SELECT AVG(salary) FROM employees GROUP BY AVG(SALARY));

51. What privilege do you need to create a function?

Answers:

  1. UPDATE
  2. CREATE ROUTINE
  3. SELECT
  4. CREATE FUNCTION
  5. No specific privilege

52. What is wrong with the following query:

select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)

Answers:

  1. In the sub query, ‘*’ should be used instead of ‘OrderID’
  2. The sub query can return more than one row, so, ‘=’ should be replaced with ‘in’
  3. The sub query should not be in parenthesis
  4. None of the above

53. Which of the following is a correct way to show the last queries executed on MySQL?

Answers:

  1. First execute SET GLOBAL log_output = ‘TABLE’; Then execute SET GLOBAL general_log = ‘ON’; The last queries executed are saved in the table mysql.general_log
  2. Edit the MySQL config file (mysql.con) and add the following line log = /var/log/mysql/mysql.log
  3. Execute VIEW .mysql_history
  4. Restart MySQL using the following line tail -f /var/log/mysql/mysql.log

54. Choose the appropriate query for the Products table where data should be displayed primarily in ascending order of the ProductGroup column. Secondary sorting should be in descending order of the CurrentStock column.

Answers:

  1. Select * from Products order by CurrentStock,ProductGroup
  2. Select * from Products order by CurrentStock DESC,ProductGroup
  3. Select * from Products order by ProductGroup,CurrentStock
  4. Select * from Products order by ProductGroup,CurrentStock DESC
  5. None of the above

55. What is the correct SQL syntax for returning all the columns from a table named “Persons” sorted REVERSE alphabetically by “FirstName”?

Answers:

  1. SELECT * FROM Persons WHERE FirstName ORDER BY FirstName DESC
  2. SELECT * FROM Persons SORT REVERSE ‘FirstName’
  3. SELECT * FROM Persons ORDER BY -‘FirstName’
  4. SELECT * FROM Persons ORDER BY FirstName DESC

56. You want to display the titles of books that meet the following criteria:

1. Purchased before November 11, 2002
2. Price is less than $500 or greater than $900

You want to sort the result by the date of purchase, starting with the most recently bought book.
Which of the following statements should you use?

Answers:

  1. SELECT book_title FROM books WHERE price between 500 and 900 AND purchase_date < ‘2002-11-11’ ORDER BY purchase_date;
  2. SELECT book_title FROM books WHERE price IN (500, 900) AND purchase_date< ‘2002-11-11’ ORDER BY purchase date ASC;
  3. SELECT book_title FROM books WHERE price < 500 OR>900 AND purchase_date DESC;
  4. SELECT book_title FROM books WHERE (price < 500 OR price > 900) AND purchase_date < ‘2002-11-11’ ORDER BY purchase_date DESC;

57. State whether true or false:
Transactions and commit/rollback are supported by MySQL using the MyISAM engine

Answers:

  1. True
  2. False

58. Consider the following table structure of students:

rollno int

name varchar(20)

course varchar(20)
What will be the query to display the courses in which the number of students enrolled is more than 5?

Answers:

  1. Select course from students where count(course) > 5;
  2. Select course from students where count(*) > 5 group by course;
  3. Select course from students group by course;
  4. Select course from students group by course having count(*) > 5;
  5. Select course from students group by course where count(*) > 5;
  6. Select course from students where count(group(course)) > 5;
  7. Select count(course) > 5 from students;
  8. None of the above

59. MySQL supports 5 different int types. Which one takes 3 bytes?

Answers:

  1. TINYINT
  2. MEDIUMINT
  3. SMALLINT
  4. INT
  5. BIGINT

60. Which of the following is the correct way to determine duplicate values?

Answers:

  1. SELECT column_duplicated, sum(*) amount FROM table_name WHERE amount > 1 GROUP BY column_duplicated
  2. SELECT column_duplicated, COUNT(*) amount FROM table_name WHERE amount > 1 GROUP BY column_duplicated
  3. SELECT column_duplicated, sum(*) amount FROM table_name GROUP BY column_duplicated HAVING amount > 1
  4. SELECT column_duplicated, COUNT(*) amount FROM table_name GROUP BY column_duplicated HAVING amount > 1

61. Examine the query:-

select (2/2/4) from tab1;

where tab1 is a table with one row. This would give a result of:

Answers:

  1. 4
  2. 2
  3. 1
  4. .5
  5. .25
  6. 8
  7. 24

62. Which of the following commands will list the tables of the current database?

Answers:

  1. SHOW TABLES
  2. DESCRIBE TABLES
  3. SHOW ALL TABLES
  4. LIST TABLES

63. Which of the following is not a MySQL statement?

Answers:

  1. ENUMERATE
  2. EXPLAIN
  3. KILL
  4. LOAD DATA
  5. SET

64. When running the following SELECT query:

SELECT ID FROM (
SELECT ID, name FROM (
SELECT *
FROM employee
)
);

The error message ‘Every derived table must have its own alias’ appears.
Which of the following is the best solution for this error?

Answers:

  1. SELECT ID FROM ( SELECT ID AS SECOND_ID, name FROM ( SELECT * FROM employee ) );
  2. SELECT ID FROM ( SELECT ID, name AS NAME FROM ( SELECT * FROM employee ) );
  3. SELECT ID FROM ( SELECT ID, name FROM ( SELECT * FROM employee ) AS T ) AS T;
  4. SELECT ID AS FIRST_ID FROM ( SELECT ID, name FROM ( SELECT * FROM employee ) );

65. Which of the following is not a Table Storage specifier in MySQL?

Answers:

  1. InnoDB
  2. MYISAM
  3. BLACKHOLE
  4. STACK

66. The REPLACE statement is:

Answers:

  1. Same as the INSERT statement
  2. Like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted
  3. There is no such statement as REPLACE

67. If you try to perform an arithmetic operation on a column containing NULL values, the output will be:

Answers:

  1. NULL
  2. An error will be generated
  3. Cannot be determined

68. Which of the following is the best way to insert a row, and to update an existing row, using a MySQL query?

Answers:

  1. Use MERGE statement
  2. Use INSERT … ON DUPLICATE KEY UPDATE statement
  3. Use ADD UNIQUE statement
  4. Use REPLACE statement

69. How will you change “Hansen” into “Nilsen” in the LastName column in the Persons Table?

Answers:

  1. UPDATE Persons SET LastName = ‘Nilsen’ WHERE LastName = ‘Hansen’
  2. UPDATE Persons SET LastName = ‘Hansen’ INTO LastName = ‘Nilsen’
  3. SAVE Persons SET LastName = ‘Nilsen’ WHERE LastName = ‘Hansen’
  4. SAVE Persons SET LastName = ‘Hansen’ INTO LastName = ‘Nilsen’

70. Which one of the following correctly selects rows from the table myTable that have NULL in column column1?

Answers:

  1. SELECT * FROM myTable WHERE column1 IS NULL
  2. SELECT * FROM myTable WHERE column1 = NULL
  3. SELECT * FROM myTable WHERE column1 EQUALS NULL
  4. SELECT * FROM myTable WHERE column1 NOT NULL
  5. SELECT * FROM myTable WHERE column1 CONTAINS NULL

71. Is the FROM clause necessary in every SELECT statement?

Answers:

  1. Yes
  2. No

72. Which command will make a backup on the whole database except the tables sessions and log?

Answers:

  1. mysqldump db_name sessions log > backup.sql
  2. mysqldump db_name | grep -vv -E “sessions|log” > backup.sql
  3. mysqldump db_name –ignore-table db_name.sessions db_name.log > backup.sql
  4. mysqldump db_name –except-table=db_name.sessions –except-table=db_name.log > backup.sql

73.Which of the following statements is true?

Answers:

  1. Replication can be a part of a load balancing strategy.
  2. Replication and clustering are complete synonyms in the context of MySQL server administration.
  3. MySQL supports only master-slave replication.
  4. MySQL does not support master-master replication.

74. Which of the following is not a valid Arithmetic operator?

Answers:

    1. +
    2. *
    3. \
    4. %
    5. All are valid

75. What are MySQL Spatial Data Types in the following list?

Answers:

      1. GEOMETRY
      2. CIRCLE
      3. SQUARE
      4. POINT
      5. POLYGON

76. Which of the following statements relating to Alias names is true?

Answers:

      1. Alias names are case sensitive
      2. Alias names are case sensitive
      3. Alias names are case in-sensitive
      4. Alias names are case sensitive on UNIX and not on Windows
      5. Alias names are case sensitive on Windows and not on UNIX
      6. Alias names case sensitivity depends on lower_case_table_names system setting

77. Examine the description of the STUDENTS table:

Answers:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:

      1. SUM(start_date)
      2. AVG(start_date)
      3. COUNT(start_date)
      4. AVG(start_date, end_date)
      5. AVG(start_date, end_date)
      6. MIN(start_date)

78. Which of the following is the correct way to change the character set to UTF8?

Answers:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:

      1. Add the following lines in my.cnf:
      2. default-character-set=utf8

        [mysqld]
        default-character-set = utf8

      1. dd the following lines in my.cnf:
        [mysqld]
        character_set_server = utf8
      2. Add the following lines in my.cnf:
        [mysqld]
        skip-character-set-client-handshake
        character_set_client=utf8
        character_set_server=utf8
      3. AVG(start_date, end_date)
      4. AVG(start_date, end_date)
      5. MIN(start_date)

78. To quote a string within a string, which of the following can you use?

Answers:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:

      1. «This is the «quoted» message»
      2. «This is the «»quoted»» message»
      3. ‘This is the «quoted» message’
      4. «This is the \»quoted\» message»

79.SELECT employee_id FROM employees WHERE commission_pct=.5 OR salary > 23000;
Which of the following statements is correct with regard to this code?
Answers:

      1. It returns employees whose salary is 50% more than $23,000
      2. It returns employees who have 50% commission rate or salary greater than $23,000
      3. It returns employees whose salary is 50% less than $23,000
      4. None of the above

80.Select which of the following is the best way to duplicate MySql Database(DB1) in to another database(DB2) without using mysqldump?

Answers:

      1. Create the target database using MySQLAdmin,
      2. Execute the following MySql query CREATE TABLE t2 SELECT * FROM t1;
      3. Execute the following MySql query CREATE TABLE x LIKE other_db.y;
      4. CREATE TABLE DB2 SELECT * FROM DB1;

81.Which of the following statement will results in 0 (false)?

Answers:

      1. SELECT «EXPERTRATING» LIKE «EXP%»
      2. SELECT «EXPERTRATING» LIKE «Exp%»
      3. SELECT BINARY «EXPERTRATING» LIKE «EXP%»
      4. SELECT BINARY «EXPERTRATING» LIKE «Exp%»
      5. All will result in 1 (true)

82.Which query will display data from the Pers table relating to Analyst, Clerk and Salesman who joined between 1/1/2005 and 1/2/2005 ?

Answers:

      1. select * from Pers where joining_date from #1/1/2005# to #1/2/2005#, job=Analyst or clerk or salesman
      2. select * from Pers where joining_date between #1/1/2005# to #1/2/2005#, job=Analyst or job=clerk or job=salesm
      3. select * from Pers where joining_date between #1/1/2005# and #1/2/2005# and
      4. None of the above

83. How can a InnoDB database be backed up without locking the tables?

Answers:

      1. mysqldump –single-transaction db_name
      2. mysqldump –force db_name
      3. mysqldump –quick db_name
      4. mysqldump –no-tablespaces db_name

85. Which of the following is not a valid Bit operator?

Answers:

      1. &
      2. &&
      3. <<
      4. |
      5. >>

86. What is the main purpose of InnoDB over MyISAM?

Answers:

      1. InnoDB is thread safe
      2. InnoDB provides a transaction safe environment
      3. InnoDB can handle table with more than 1000 columns
      4. InnoDB provides FULLTEXT indexes
      5. None of the above

87. View the following Create statement:
1. Create table Pers
2. (EmpNo Int not null,
3. EName Char not null,
4. Join_dt Date not null,
5. Pay Int)
Answers:

      • 1
      • 2
      • 3
      • 4
      • 5

88.What will happen if some of the columns in a table are of char datatype and others are of varchar datatype?

Answers:

      • Nothing will happen
      • MySQL will generate an error
      • MySQL will convert all varchar datatypes into char
      • MySQL will convert all char datatypes into varchar

89.If you insert (00) as the value of the year in a date column, what will be stored in the database?

Answers:

      • 0000
      • 1900
      • 2000
      • Ambiguous, cannot be determined

90.Which of the following statements is true is regards to whether the schema integration problem between development, test, and production servers can be solved?

Answers:

      • True, only can create migration solution in .NET programming language.
      • True, it can be solve by migration solution. These solutions vary by programming language.
      • Both A and B
      • None of the above

91. Which of the following is not a valid Logical operator?

Answers:

      1. &
      2. &&
      3. AND
      4. NOT

92. What is true regarding the TIMESTAMP data type?

Answers:

      1. For one TIMESTAMP column in a table, you can assign the current timestamp as the default value and the auto-update value
      2. TIMESTAMP columns are NOT NULL by default, cannot contain NULL values, and assigning NULL assigns the current timestamp
      3. When the server runs with the MAXDB SQL mode enabled, TIMESTAMP is identical with DATETIME
      4. A TIMESTAMP column cannot have a default value
      5. None of the above is true

93. Which of the following is not a SQL operator?

Answers:

      1. Between..and..
      2. Like
      3. In
      4. Is null
      5. Not in
      6. All of the above are SQL operators

94. Which of the following is not a SQL operator?

Answers:

      1. Between..and..
      2. Like
      3. In
      4. Is null
      5. Not in
      6. All of the above are SQL operators

95.Which of the following is not a valid Comparison operator?

Answers:

      1. ==
      2. <=>
      3. !=
      4. <>
      5. REGEXP
      6. All of the above are SQL operators

96.What will happen if you write the following statement on the MySQL prompt?
SELECT NOW();

Answers:

      1. It will display the current date
      2. It will display the error message as now does not exist.
      3. It will display a syntax error near ‘()’

97.Assuming the column col1 in table tab1 has the following values:
2,3,NULL,2,3,1
What will be the output of the select statement below?
SELECT count(col1) FROM tab1

Answers:

      1. 6
      2. 5
      3. 4
      4. 3

98. What is the correct SQL syntax for selecting all the columns from the table Persons where the LastName is alphabetically between (and including) «Hansen» and «Pettersen»?
CREATE TABLE `Persons` (
`LastName` varchar(244) NOT NULL DEFAULT »
) ENGINE=InnoDB;
REPLACE INTO Persons VALUE (‘Hansen’),(‘Pettersen’),(‘Nilsen’),(‘Smith’);

Answers:

      1. SELECT * FROM Persons WHERE LastName > ‘Hansen’, LastName <‘Pettersen’
      2. SELECT LastName > ‘Hansen’ AND LastName < ‘Pettersen’ FROM Persons
      3. SELECT * FROM persons WHERE LastName > ‘Hansen’ AND LastName > ‘Pettersen’
      4. SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pettersen’

99.Which of the following statements is correct in regards to the syntax of the code below?
SELECT table1.this, table2.that, table2.somethingelse
FROM table1
INNER JOIN table2 ON table1.foreignkey = table2.primarykey
WHERE (some other conditions)

Answers:

      1. Using the older syntax is more subject to error. If use inner joins without an ON clause, will get a syntax error.
      2. INNER JOIN is ANSI syntax. It is generally considered more readable, especially when joining lots of tables. It can also be easily replaced with an OUTER JOIN whenever a need arises
      3. (INNER JOIN) ON will filter the data before applying WHERE clause. The subsequent join conditions will be executed with filtered data which makes better performance. After that only WHERE condition will apply filter conditions.
      4. All of the Above

100.Considering table foo has been created with:create table foo (id int primary key auto_increment, name varchar(100));
Is the following query syntactically valid?
delete from foo where id = id-1;

Answers:

      1. Yes
      2. No

101.The STUDENT_GRADES table has these columns:
STUDENT_ID INT
SEMESTER_END DATE
GPA FLOAT

Which of the following statements finds the highest Grade Point Average (GPA) per semester?
Answers:

      1. SELECT MAX(GPA) FROM STUDENT_GRADES WHERE GPA IS NOT NULL
      2. SELECT GPA FROM STUDENT_GRADES GROUP BY SEMESTER_END
      3. SELECT MAX(GPA) FROM STUDENT_GRADES GROUP BY SEMESTER_END
      4. SELECT TOP 1 GPA FROM STUDENT_GRADES GROUP BY SEMESTER_END
      5. None of the above

102.Which of the following queries is valid?
Answers:

      1. Select * from students where marks > avg(marks);
      2. Select * from students order by marks where subject = ‘SQL’;
      3. Select * from students having subject =’SQL’;
      4. Select name from students group by subject, name;
      5. Select group(*) from students;
      6. Select name,avg(marks) from students;
      7. None of the above

103.Which of the following are aggregate functions in MySQL?
Answers:

    1. Avg
    2. Select
    3. Order By
    4. Sum
    5. Union
    6. Group by
    7. Having
Advertisements

Upwork Latest Javascript Test 2017

Javascript Test

1. Which of the following Array methods in JavaScript runs a function on every item in the Array and collects the result from previous calls, but in reverse?

Answers:

  1. reduce()
  2. reduceRight()
  3. everse()
  4. pop()

2. Which of the following is true about setTimeOut()?

Answers:

  1. The statement(s) it executes run(s) only once.
  2. It pauses the script in which it is called.
  3. clearTimeOut() won’t stop its execution.
  4. The delay is measured in hundredths of a second.
  5. It is required in every JavaScript function.

3. How can the operating system of the client machine be detected?

Answers:

  1. It is not possible using JavaScript.
  2. Using the navigator object
  3. Using the window object
  4. Using the document object
  5. None of these.

4. Which of the following prints “AbBc”?

Answers:

  1. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  2. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’c'[‘toUpperCase’](); alert(result);
  3. var b = ‘a’; var result = b.toUpperCase() + b + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  4. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +C; alert(result);

5. Which of the following descriptions is true for the code below?

var object0 = {};
Object.defineProperty(object0, “prop0”, { value : 1, enumerable:false, configurable : true });
Object.defineProperty(object0, “prop1”, { value : 2, enumerable:true, configurable : false });
Object.defineProperty(object0, “prop2”, { value : 3 });
object0.prop3 = 4;

Answers:

  1. Object ‘object0’ contains 4 properties. Property ‘prop2’ and property ‘prop3’ are available in the for…in loop. Property ‘prop0’ and property ‘prop1’ are available to delete.
  2. Object ‘object0’ contains 4 properties. Property ‘prop1’ and property ‘prop2’ are available in the for…in loop. Property ‘prop2’ and property ‘prop3’ are available to delete.
  3. Object ‘object0’ contains 4 properties. Property ‘prop0’ and property ‘prop2’ are available in the for…in loop. Property ‘prop0’ and property ‘prop2’ are available to delete.
  4. Object ‘object0’ contains 4 properties. Property ‘prop1’ and property ‘prop3’ are available in the for…in loop. Property ‘prop0’ and property ‘prop3’ are available to delete.

6. Performance-wise, which is the fastest way of repeating a string in JavaScript?

Answers:

  1. String.prototype.repeat = function( num ) { return new Array( num + 1 ).join( this ); }
  2. function repeat(pattern, count) { if (count < 1) return ”; var result = ”; while (count > 0) { if (count & 1) result += pattern; count >>= 1, pattern += pattern; } return result; }
  3. String.prototype.repeat = function(count) { if (count < 1) return ”; var result = ”, pattern = this.valueOf(); while (count > 0) { if (count & 1) result += pattern; count >>= 1, pattern += pattern; } return result; };
  4. String.prototype.repeat = function (n, d) { return –n ? this + (d || ”) + this.repeat(n, d) : ” + this };

7. Consider the following variable declarations:

var a=”adam”
var b=”eve”

Which of the following would return the sentence “adam and eve”?

Answers:

  1. a.concatinate(“and”, b)
  2. a.concat(“and”, b)
  3. a.concatinate(” and “, b)
  4. a.concat(” and “, b)

8. Which of the following code snippets will correctly split “str”?

Answers:

  1. var str = ‘something — something_else’; var substrn = str.split(‘ — ‘);
  2. var str = ‘something — something_else’; var substrn = split.str(‘ — ‘);
  3. var str = ‘something — something_else’; var substrn = str.split(‘ – ‘,’ – ‘);
  4. var str = ‘something — something_else’; var substrn = split.str(‘ – ‘,’ – ‘);

9. Which object can be used to ascertain the protocol of the current URL?

Answers:

  1. document
  2. window
  3. history
  4. browser
  5. form
  6. location

10. Which of the following best describes a “for” loop?

Answers:

  1. “for” loop consists of six optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
  2. “for” loop consists of five optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
  3. “for” loop consists of four optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
  4. “for” loop consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.

11. Which of the following descriptions best describes the code below?


var variable1 = { fastFood: “spaghetti”, length: 10 };
Object.freeze(variable1);
variable1.price = 50;
delete variable1.length;

Answers:

  1. Object is frozen, a property named “price” is added in the variable1 object, a property named “length” is deleted from this object. At the end of the code, the object “variable1” contains 2 properties.
  2. Object is frozen, a property named “price” is not added in the variable1 object, a property named “length” is deleted from this object. At the end of the code, object “variable1” contains 1 properties.
  3. Object is frozen, a property named “price” is added in the variable1 object, a property named “length” is not deleted from this object. At the end of the code, object “variable1” contains 1 properties.
  4. Object is frozen, a property named “price” is not added in the variable1 object, a property named “length” is not deleted from this object. At the end of the code, object “variable1” contains 2 properties.

12. Which of the following is not a valid HTML event?

Answers:

  1. ondblclick
  2. onmousemove
  3. onclick
  4. onblink

13. Analyze the following code snippet which uses a Javascript Regular Expression character set. What will be the output of this code?

<html>
<body>


var str = “Is this enough?”;
var patt1 = new RegExp(“[^A-J]”);
var result = str.match(patt1);
document.write(result);

</body>
</html

Answers:

  1. I
  2. Is
  3. s
  4. I,s,

14. Consider the following image definition:
<img id=”logo” src=”companylogo1.gif” height=”12″ width=”12″ >
Which of the following will change the image to companylogo2.gif when the page loads?

Answers:

  1. logo.source=”companylogo2.gif”
  2. logo.source=”companylogo1.gif”
  3. document.getElementById(‘logo’).src=”companylogo1.gif”
  4. document.getElementById(‘logo’).src=”companylogo2.gif”

15. What is the final value of the variable bar in the following code?

var foo = 9;
bar = 5;
(function() {
var foo = 2;
bar= 1;
}())
bar = bar + foo;

Answers:

  1. 10
  2. 14
  3. 3
  4. 7

16. Which of the following are JavaScript unit testing tools?

Answers:

  1. Buster.js, jQuery, YUI Yeti
  2. QUnit, Modernizr, JsTestDriver
  3. Node.js, Modernizr, Jasmine
  4. Buster.js, YUI Yeti, Jasmine

17. Which of the following can be used for disabling the right click event in Internet Explorer?

Answers:

  1. event.button == 2
  2. event.button == 4
  3. event.click == 2
  4. event.click == 4

18. An image tag is defined as follows:
<img id=”ERImage” width=”100″ height=”100″ onmouseover=”ImageChange()” src=”Image1.jpg”>
The purpose of the ImageChange() function is to change the image source to Image2.jpg. Which of the following should the ImageChange() function look like?

Answers:

  1. document.getElementById(‘ERImage’).src=”Image1.jpg”
  2. document.getElementById(‘ERImage’).src=”Image2.jpg”
  3. document.getElementById(‘ERImage’).style.src=”Image1.jpg”
  4. document.getElementById(‘ERImage’).style.src=”Image2.jpg”

19. Consider the following JavaScript alert:

function message() {
alert(“Welcome to ExpertRating!!!”)
}

Which of the following will run the function when a user opens the page?

Answers:

  1. body onload=”message()”
  2. body onunload=”message()”
  3. body onsubmit=”message()”
  4. body onreset=”message()”

20. Which of the following code snippets will correctly get the length of an object?

Answers:

  1. var newObj = new Object(); newObj[“firstname”] = “FirstName”; newObj[“lastname”] = “LastName”; newObj[“age”] = 21; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(index)) size++; } return size; }; var size = Object.size(newObj);
  2. var newObj = new Object(); newObj[“firstname”] = “FirstName”; newObj[“lastname”] = “LastName”; newObj[“age”] = 21; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(value)) size++; } return size; }; var size = Object.size(newObj);
  3. var newObj = new Object(); newObj[“firstname”] = “FirstName”; newObj[“lastname”] = “LastName”; newObj[“age”] = 21; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(length)) size++; } return size; }; var size = Object.size(newObj);
  4. var newObj = new Object(); newObj[“firstname”] = “FirstName”; newObj[“lastname”] = “LastName”; newObj[“age”] = 21; Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) size++; } return size; }; var size = Object.size(newObj);

21. In an HTML page, the form tag is defined as follows:
<form onsubmit=”return Validate()” action=”http://www.mysite.com/”>
The validate() function is intended to prevent the form from being submitted if the name field in the form is empty. What should the validate() function look like?

Answers:

  1. function Validate() { if(document.forms[0].name.value == “”) return true; else return false; }
  2. function Validate() { if(document.forms[0].name.value == “”) return false; else return true; }
  3. script type=”text/javascript”> function Validate() { if(document.forms[0].name== “”) return false; else return true; } </script>
  4. function Validate() { if(document.forms[0].name == “”) return true; else return false; }

22. Which of the following code snippets changes an image on the page?

Answers:

  1. var img = document.getElementById(“imageId”); img.src = “newImage.gif”;
  2. var img = document.getElementById(“imageId”); img.style.src = “newImage.gif”;
  3. var img = document.getElementById(“imageId”); img.src.value = “newImage.gif”;
  4. var img = document.getElementById(“imageId”); img = “newImage.gif”;

23. Which of the following results is returned by the JavaScript operator “typeof” for the keyword “null”?

Answers:

  1. function
  2. object
  3. string
  4. number

24. What will be the final value of the variable “apt”?

var apt=2;
apt=apt<<2;

Answers:

  1. 2
  2. 4
  3. 6
  4. 8
  5. 16

25. How can a JavaScript object be printed?

Answers:

  1. console.log(obj)
  2. console.print(obj)
  3. console.echo(obj);
  4. None of these

26. Which of the following is the correct syntax for using the JavaScript exec() object method?

Answers:

  1. RegExpObject.exec()
  2. RegExpObject.exec(string)
  3. RegExpObject.exec(parameter1,parameter2)
  4. None of these

27. Having an array object var arr = new Array(), what is the best way to add a new item to the end of an array?

Answers:

  1. arr.push(“New Item”)
  2. arr[arr.length] = “New Item”
  3. arr.unshift(“New Item”)
  4. arr.append(“New Item”)

28. Consider the following JavaScript validation function:

function ValidateField()
{
if(document.forms[0].txtId.value ==””)
{return false;}

return true;
}
Which of the following options will call the function as soon as the user leaves the field?

Answers:

  1. input name=txtId type=”text” onreset=”return ValidateField()”
  2. input name=txtId type=”text” onfocus=”return ValidateField()”
  3. input name=txtId type=”text” onsubmit=”return ValidateField()”
  4. input name=txtId type=”text” onblur=”return ValidateField()”

29. Which of following uses the “with” statement in JavaScript correctly?

Answers:

  1. with (document.getElementById(“blah”).style) { background = “black”; color = “blue”; border = “1px solid green”; }
  2. with document.getElementById(“blah”).style background = “black”; color = “blue”; border = “1px solid green”; End With
  3. With document.getElementByName(“blah”).style background = “black”; color = “blue”; border = “1px solid green”; End With
  4. with (document.getElementById(“blah”).style) { .background = “black”; .color = “blue”; .border = “1px solid green”; }

30. Consider the following JavaScript validation function:


function ValidateField()
{
if(document.forms[0].txtId.value ==””)
{return false;}

return true;
}

Which of the following options will call the function as soon as the user leaves the field?

Answers:

  1. input name=txtId type=”text” onreset=”return ValidateField()”
  2. input name=txtId type=”text” onfocus=”return ValidateField()”
  3. input name=txtId type=”text” onsubmit=”return ValidateField()”
  4. input name=txtId type=”text” onblur=”return ValidateField()”

31. Which of the following modifiers must be set if the JavaScript lastIndex object property was used during pattern matching?

Answers:

  1. i
  2. m
  3. g
  4. s

32. Consider the following image definition:

<img id=”logo” src=”companylogo1.gif” height=”12″ width=”12″ >

Which of the following will change the image to “companylogo2.gif” when the page loads?

Answers:

  1. logo.source=”companylogo2.gif”
  2. logo.source=”companylogo1.gif”
  3. document.getElementById(‘logo’).src=”companylogo1.gif”
  4. document.getElementById(‘logo’).src=”companylogo2.gif”

33. Which of the following will check whether the variable vRast exists or not?

Answers:

  1. if (typeof vRast=”undefined”) {}
  2. if (typeof vRast ==”undefined”) {}
  3. if (vRast.defined =true) {}
  4. if (vRast.defined ==true) {}

34. What would be the use of the following code?

function validate(field) {
var valid=”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”;
var ok=”yes”;
var temp;

for(var i=0;i<field.value.length;i++) {
temp=”” + field.value.substring(i,i+1)

if(valid.indexOf(temp)==”-1”) {
ok=”no”;
}
}

if(ok==”no”) {
alert(”error”);
field.focus();
}
}

Answers:

  1. It will force a user to enter only numeric values.
  2. It will force a user to enter only alphanumeric values.
  3. It will force a user to enter only English alphabet character values.
  4. None of these.

35. An image tag is defined as follows:

<img id=”ERImage” width=”100″ height=”100″ onmouseover=”ImageChange()” src=”Image1.jpg”>

The purpose of the ImageChange() function is to change the image source to “Image2.jpg”. Which of the following should the ImageChange() function look like?

Answers:

  1. document.getElementById(‘ERImage’).src=”Image1.jpg”
  2. document.getElementById(‘ERImage’).src=”Image2.jpg”
  3. document.getElementById(‘ERImage’).style.src=”Image1.jpg”
  4. document.getElementById(‘ERImage’).style.src=”Image2.jpg”

36. Which of the following choices will detect if “variableName” declares a function?


var variableName= function(){};

Answers:

  1. return variableName;
  2. nameof variableName;
  3. isFunction variableName;
  4. typeof variableName;

37. Which of the following choices will change the source of the image to “image2.gif” when a user clicks on the image?

Answers:

  1. img id=”imageID” src=”image1.gif” width=”50″ height=”60″ onmousedown=”changeimg(image1.gif)” onmouseup=”changeimg(image2.gif)”
  2. img id=”imageID” src=”image1.gif” width=”50″ height=”60″ onmouseclick=”changeimg(image2.gif)” onmouseup=”changeimg(image1.gif)”
  3. img id=”imageID” src=”image2.gif” width=”50″ height=”60″ onmousedown=”changeimg(image1.gif)” onmouseup=”changeimg(image2.gif)”
  4. img id=”imageID” src=”image2.gif” width=”50″ height=”60″ onmousedown=”changeimg(image2.gif)” onmouseup=”changeimg(image1.gif)”
  5. img id=”imageID” src=”image1.gif” width=”50″ height=”60″ onmousedown=”changeimg(‘image2.gif’)” onmouseup=”changeimg(‘image1.gif’)”

38. How can created cookies be deleted using JavaScript?

Answers:

  1. They can’t be deleted. They are valid until they expire.
  2. Overwrite with an expiry date in the past
  3. Use escape() on the value of the path attribute
  4. Use unescape() on the value of the path attribute
  5. The cookie file will have to be removed from the client machine.
  6. Wait till the expiry date is reached

39. What would be the value of ‘ind’ after execution of the following code?

var msg=”Welcome to ExpertRating”
var ind= msg.substr(3, 3)

Answers:

  1. lco
  2. com
  3. ome
  4. Welcome

40. Are the two statements below interchangeable?

object.property
object[”property”]

Answers:

  1. Yes
  2. No

41. Which of the following is not a valid method in generator-iterator objects in JavaScript?

Answers:

  1. send()
  2. throw()
  3. next()
  4. stop()

42. Which of the following code snippets will return all HTTP headers?

Answers:

  1. var req = new XMLHttpRequest(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); alert(headers);
  2. var req = new XMLHttpAccess(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); alert(headers);
  3. var req = new XMLHttpRequest(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.getResponseHeader().toLowerCase(); alert(headers);
  4. var req = new XMLHttpRequestHeader(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.retrieveAllResponseHeaders().toLowerCase(); alert(headers);

43. Consider the following JavaScript alert:


function message() {
alert(“Welcome to ExpertRating!!!”)
}

Which of the following will run the function when a user opens the page?

Answers:

  1. body onload=”message()”
  2. body onunload=”message()”
  3. body onsubmit=”message()”
  4. body onreset=”message()”

44. Which of the following is the most secure and efficient way of declaring an array?

Answers:

  1. var a = []
  2. var a = new Array()
  3. var a = new Array(n)
  4. var a

45. Which of the following Regular Expression pattern flags is not valid?

Answers:

  1. gi
  2. p
  3. i
  4. g

46. Which of the following built-in functions is used to access form elements using their IDs?

Answers:

  1. getItem(id)
  2. getFormElement(id)
  3. getElementById(id)
  4. All of these

47. Which of the following statements is correct?

Answers:

  1. There is no undefined property in JavaScript.
  2. Undefined object properties can be checked using the following code: if (typeof something == null) alert(“something is undefined”);
  3. It is not possible to check for undefined object properties in JavaScript.
  4. Undefined object properties can be checked using the following code: if (typeof something === “undefined”) alert(“something is undefined”);

48. Which of the following correctly uses a timer with a function named rearrange()?

Answers:

  1. tmr=setTimeout(“rearrange ()”,1)
  2. tmr=Timer(1,”rearrange ()”)
  3. tmr=Timer(“rearrange ()”,1)
  4. tmr=setTimeout(1,”rearrange ()”)

49. Which of the following can be used to escape the ‘ character?

Answers:

  1. *
  2. \
  3. @
  4. #
  5. %
  6. |
  7. ~

50. Which event can be used to validate the value in a field as soon as the user moves out of the field by pressing the tab key?

Answers:

  1. onblur
  2. onfocus
  3. lostfocus
  4. gotfocus
  5. None of these

51. When setting cookies with JavaScript, what will happen to the cookies.txt data if the file exceeds the maximum size?

Answers:

  1. The script automatically generates a run-time error.
  2. The script automatically generates a load-time error.
  3. All processes using document.cookie are ignored.
  4. The file is truncated to the maximum length.

52. Which of the following are not global methods and properties in E4X?

Answers:

  1. ignoreComments
  2. ignoreWhiteSpace
  3. setName()
  4. setNamespace()
  5. ignoreComments and ignoreWhiteSpace
  6. setName() and setNamespace()

53. Which of the following will change the color of a paragraph’s text to blue when a user hovers over it, and reset it back to black when the user hovers out?

Answers:

  1. <p onmouseover=”style.color=’black’” onmouseout=”style.color=’blue’”> The text of the paragraph..</p>
  2. <p onmouseover=”style.color=’blue’” onmouseout=”style.color=’black’”> The text of the paragraph..</p>
  3. <p onmouseout=”style.color=’blue’”> The text of the paragraph..</p>
  4. <p onmouseover=”style.color=’blue’”> The text of the paragraph..</p>
  5. <p onmousein=”style.color=’blue’” onmouseout=”style.color=’black’”> The text of the paragraph..</p>

54. What is the purpose of while(1) in the following JSON response?

while(1);[[‘u’,[[‘smsSentFlag’,’false’],[‘hideInvitations’,’false’],[‘remindOnRespondedEventsOnly’,’true’],[‘hideInvitations_remindOnRespondedEventsOnly’,’false_true’],[‘Calendar ID stripped for privacy’,’false’],[‘smsVerifiedFlag’,’true’]]]]

Answers:

  1. It’s invalid JSON code.
  2. It makes it difficult for a third-party to insert the JSON response into an HTML document with a tag.
  3. It iterates the JSON response.
  4. It prevents the JSON response from getting executed.

55. Consider the three variables:

someText = ‘JavaScript1.2’;
pattern = /(w+)(d).(d)/i;
outCome = pattern.exec(someText);

What does outCome[0] contain?

Answers:

  1. true
  2. false
  3. JavaScript1.2
  4. null
  5. 0

56. Which of the following choices will turn a string into a JavaScript function call (case with objects) of the following code snippet?


window.foo = {
bar: {
baz: function() {
alert(‘Hello!’);
}
}
};

Answers:

  1. bar[‘baz’]();
  2. object[‘foo’][‘bar’][‘baz’]();
  3. document[‘foo’][‘bar’][‘baz’]();
  4. window[‘foo’][‘bar’][‘baz’]();

57. Which of the following determines whether cookies are enabled in a browser or not?

Answers:

  1. (navigator.Cookie)? true : false
  2. (application.cookieEnabled)? true : false
  3. (navigator.cookieEnabled)? true : false
  4. (application.cookie)? true : false

58. Which of the following options can be used for adding direct support for XML to JavaScript?

Answers:

  1. E4X
  2. egex
  3. Generators and Iterators
  4. let

59. Which of the following will detect which DOM element has the focus?

Answers:

  1. document.activeElement
  2. document.ready
  3. document.referrer
  4. document.getelementbyid

60. Which of the following will randomly choose an element from an array named myStuff, given that the number of elements changes dynamically?

Answers:

  1. randomElement = myStuff[Math.floor(Math.random() * myStuff.length)];
  2. randomElement = myStuff[Math.ceil(Math.random() * myStuff.length)];
  3. randomElement = myStuff[Math.random(myStuff.length)];
  4. randomElement = Math.random(myStuff.length);

61. How can global variables be declared in JavaScript?

Answers:

  1. All variables are local in JavaScript.
  2. Declare the variable between the ‘script’ tags, and outside a function to make the variable global
  3. Precede the variable name with the constant global
  4. Declare the variable in an external file

62. Which of the following objects in JavaScript contains the collection called “plugins”?

Answers:

  1. Location
  2. Window
  3. Screen
  4. Navigator

63. What will be output of the following code?

function testGenerator() {
yield “first”;
document.write(“step1”);

yield “second”;
document.write(“step2”);

yield “third”;
document.write(“step3”);
}

var g = testGenerator();
document.write(g.next());
document.write(g.next());

Answers:

  1. firststep1second
  2. step1step2
  3. step1
  4. step1step2step3

64. Which of the following methods will copy data to the Clipboard?

Answers:

  1. execClipboard(‘Copy’)
  2. copyCommand(‘Clipboard’)
  3. execCommand(‘Copy’)
  4. execClipboard(‘Copy’)

65. Which of the following code snippets trims whitespace from the beginning and end of the given string str?

Answers:

  1. str.replace(/^s+|s+$/g, ”);
  2. str.replace(/^s+/,”);
  3. str.replace(/s+$/,”);
  4. str.replace(/s+/g,’ ‘);

66. What is the difference between call() and apply()?

Answers:

  1. The call() function accepts an argument list of a function, while the apply() function accepts a single array of arguments.
  2. The apply() function accepts an argument list of a function, while the call() function accepts a single array of arguments.
  3. The call() function accepts an object list of a function, while the apply() function accepts a single array of an object.
  4. The call() function accepts an object list of a function, while the apply() function accepts a single array of an object.

67. Which of the following code snippets is more efficient, and why?


for(i=0;i
document.images[i].src=”blank.gif”;


var theimages = document.images;
for(i=0;i
theimages[i].src=”blank.gif”

Answers:

  1. Both are equally efficient.
  2. The first code is more efficient as it contains less code.
  3. The first code is more efficient as it employs object caching.
  4. The second code is more efficient as it employs object caching.

68. What is the meaning of obfuscation in JavaScript?

Answers:

  1. Obfuscation is a keyword in JavaScript.
  2. Making code unreadable using advanced algorithms.
  3. Decrypting encrypted source code using advanced algorithms.
  4. None of these.

69. Which of the following JavaScript Regular Expression modifiers finds one or more occurrences of a specific character in a string?

Answers:

  1. ?
  2. *
  3. +
  4. #

70. Which of the following is not a valid JavaScript operator?

Answers:

  1. |
  2. ===
  3. %=
  4. ^

71. Which of the following code snippets returns “[object object]”?

Answers:

  1. var o = new Object(); o.toSource();
  2. var o = new Object(); o.valueOf();
  3. var o = new Object(); o.toString();
  4. var o = new Object(); o.getName();

72. Which of the following can be used to invoke an iframe from a parent page?

Answers:

  1. window.frames
  2. document.getElementById
  3. document.getelementsbyname
  4. document.getelementsbyclassname

73. Select the following function that shuffles an array?

Answers:

  1. function shuffle(array) { var tmp, current, top = array.length; if(top) while(–top) { current = Math.floor(Math.random() * (top + 1)); tmp = array[current]; array[current] = array[top]; array[top] = tmp; } return array; }
  2. function shuffle(array) { return array.sort(function(a,b) { return (a-b); }); }
  3. function shuffle(array) { var results = new Array(); var sorted_arr = array.sort(); for (var i = 0; i < array.length – 1; i++) { if (sorted_arr[i + 1] == sorted_arr[i]) { results.push(sorted_arr[i]); } } return results; }
  4. function shuffle(array) { for (var tmp, cur, top=array.length; top–;){ cur = (Math.random() * (top + 1)) << 0; tmp = array[cur]; array[cur] = array[top]; array[top] = tmp; } return array.sort(); }

74. Which of the following code snippets removes objects from an associative array?

Answers:

  1. delete array[“propertyName”];
  2. array.propertyName.remove();
  3. array.splice(index, 1);
  4. array[“propertyName”].remove();

75. What is the error in the statement: var charConvert = toCharCode(‘x’);?

Answers:

  1. toCharCode() is a non-existent method.
  2. Nothing. The code will work fine.
  3. toCharCode only accepts numbers.
  4. toCharCode takes no arguments.

76. What value would JavaScript assign to an uninitialized variable?

Answers:

  1. NaN
  2. null
  3. undefined
  4. false

77. What does the following JavaScript code do?

contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}

Answers:

  1. It calculates an array’s length.
  2. It compares ‘a’ and ‘obj’ in an array.
  3. The code will cause an error.
  4. It checks if an array contains ‘obj’.

78. If an image is placed styled with z-index=-1 and a text paragraph is overlapped with it, which one will be displayed on top?

Answers:

  1. The paragraph.
  2. The image.
  3. It depends on other rules.

79. Which of the following code snippets gets an image’s dimensions (height & width) correctly?

Answers:

  1. var img = document.getElementById(‘imageid’); var width = img.clientWidth; var height = img.clientHeight;
  2. var img = document.getElementById(‘imageid’); var width = img.width; var height = img.height;
  3. var img = document.getElementById(‘imageid’); var width = img.getAttribute(‘width’); var height = img.getAttribute(‘height’);
  4. var img=document.getElementById(“imageid”); var width=img.offsetWidth; var height=img.offsetHeight;

80. Which of the following are correct values of variableC, and why?


variableA = [6,8];
variableB =[7,9];
variableC = variableA + variableB;

Answers:

  1. 6, 7, 8 and 9. The + operator is defined for arrays, and it concatenates strings, so it converts the arrays to strings.
  2. 6, 15 and 9. The + operator is defined for arrays, and it concatenates numbers, so it converts the arrays to numbers.
  3. 6, 8, 7 and 9. The + operator is defined for arrays, and it concatenates strings, so it converts the arrays to strings.
  4. 6, 87 and 9. The + operator is not defined for arrays, and it concatenates strings, so it converts the arrays to strings.

81. The following are the samples for getting a selected value in the from a dropdown list:

<select id=”ddlViewBy”>
<option value=”1″>test1</option>
<option value=”2″ selected=”selected”>test2</option>
<option value=”3″>test3</option>
</select>

Which code block is correct?

Answers:

  1. var e = document.getElementById(“ddlViewBy”); var strUser = e.options[e.selectedIndex].text;
  2. var e = document.getElementById(“ddlViewBy”); var strUser = e.options[e.selectedIndex].value;
  3. var e = document.getElementByName(“ddlViewBy”); var strUser = e.options[e.selectedIndex].text;
  4. var e = document.getElementByName(“ddlViewBy”); var strUser = e.options[e.selectedIndex].value;

82. var profits=2489.8237

Which of the following code(s) produces the following output?

output : 2489.824

Answers:

  1. profits.toFixed(4)
  2. profits.toFixed(3)
  3. profits.formatDollar(3)
  4. profits.nuberFormat(3)

83. A form contains two fields named id1 and id2. How can you copy the value of the id2 field to id1?

Answers:

  1. document.forms[0].id1.value=document.forms[0].id2.value
  2. document.forms[0].id2.value=document.forms[0].id1.value
  3. document.id1.value=document.id2.value
  4. document.id2.value=document.id1.value

84. Which of the following code snippets will toggle a div element’s background color?

<button id=”toggle”>Toggle</button>

Change Background Color.

Answers:

  1. var button = document.getElementById(‘toggle’); button.click = function() { terd.style.backgroundColor = terd.style.backgroundColor == ‘blue’ ? ‘red’ : ‘blue’; };
  2. var button = document.getElementById(‘toggle’); button.ready = function() { terd.style.backgroundColor = terd.style.backgroundColor == ‘blue’ ? ‘red’ : ‘blue’; };
  3. var button = document.getElementById(‘toggle’); button.focus = function() { terd.style.backgroundColor = terd.style.backgroundColor == ‘blue’ ? ‘red’ : ‘blue’; };
  4. var button = document.getElementById(‘toggle’); button.onclick = function() { terd.style.backgroundColor = terd.style.backgroundColor == ‘blue’ ? ‘red’ : ‘blue’; };

85. How can the user’s previously navigated page be determined using JavaScript?

Answers:

  1. It is not possible in JavaScript. This can be done only through server-side scripting.
  2. Using the document.referrer property
  3. Using the window object
  4. None of these

86. Which of the following is not a valid method for looping an array?

Answers:

  1. var a= [1,2]; for (var i = 0; i < a.length; i++) { alert(a[i]); }
  2. var a= [1,2]; a.forEach( function(item) { alert(item); })
  3. var a= [1,2]; a.map( function(item) { alert(item); })
  4. var a= [1,2]; a.loop( function(item) { alert(item); })

87. Which of the following correctly sets a class for an element?

Answers:

  1. document.getElementById(elementId).className = “Someclass”;
  2. document.getElementById(elementId).setAttribute(“className”, “Someclass”);
  3. document.getElementById(elementId).class = “Someclass”;
  4. document.getElementById(elementId).style = “Someclass”;

88. An HTML form contains 10 checkboxes all named “chkItems”. Which JavaScript function can be used for checking all the checkboxes together?

Answers:

  1. function CheckAll() { for (z = 0; z < document.forms.chkItems.length; z++) { document.forms.chkItems[z].checked=true } }
  2. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems[z].checked=true } }
  3. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems.list[z].checked=true } }
  4. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems.list[z].checked=false } }

89.Which of the following is not a valid Date Object method in JavaScript?

Answers:

  1. parse()
  2. setDay()
  3. setTime()
  4. valueOf()

90.Which event can detect when the user highlights text within a text or textarea object?

Answers:

  1. onSelect()
  2. onBlur
  3. onChange()
  4. onMove
  5. None of these

91.Consider the following code snippet:
var myJSONObject =
{«ircEvent»: «PRIVMSG», «method»: «newURI», «regex»: «^http://.*»};

What is the best way to remove the property ‘regex’, so the result would be this code snippet?

myJSONObject ==
{«ircEvent»: «PRIVMSG», «method»: «newURI»};

Answers:

  1. myJSONObject.regex.delete;
  2. myJSONObject.regex.remove;
  3. delete myJSONObject.regex;
  4. remove myJSONObject.regex;

92.Which of the following is the best way to show both single and double quotes in the same sentence

Answers:

  1. alert(«It’s «+’»game»‘+» time.»);
  2. alert(‘It\’s \»game\» time.’);
  3. alert(‘It\’\s «game» time.’);
  4. alert(‘It\’s «game» time.’);

93.Which of the following statements is true regarding importing JavaScript files inside of other JavaScript files?

Answers:

  1. There is no import/include/require keyword in JavaScript, but there ways to import JS files inside of other JS files.
  2. There is an import keyword in JavaScript, which allows importing JS files inside of other JS files.
  3. There is no option to do so in JavaScript.

94. Which of the following shortcuts can be used for writing multiple document.write statements?

Answers:

  1. for(document){}
  2. with(document) {}
  3. withThis(document){}
  4. None of these

95.In JavaScript, the encodeURI() function is used to encode special characters. Which of the following special characters is/are an exception to that rule?
A. £
B. €
C. @
D. $
Answers:

  1. A
  2. B
  3. C
  4. D
  5. A and B
  6. C and D

96.Consider the following code:

<form>
<textarea id=»foo» name=»foo»></textarea>
</form>Which of the following is the best method to get the line number of the form’s text area?
Answer:

  1. A foo.value.split(/\r\n\|\r\|\n/g);
  2. foo.value.split(/\r\/n\|\r\|\n/g);
  3. foo.value.split(/\rn\|\r\|\n/g);
  4. foo.value.split(/\r\n|\r|\n/g);

97.Consider the following code:
var setter=new Object()
setter.color=»blue»
How would you delete the color property of the variable seter?

Answer:

  1. setter.color delete;
  2. delete setter.color
  3. delete(setter.color)
  4. setter.color.delete

98. Is the following statement regarding expression closures in JavaScript true or false?
The syntax function(x) {return x*x;} can be written as function(x) x*x.

Answer:

  1. Yes
  2. No

99.Which of the following statements regarding this String prototype is correct?
String.prototype.doSomething = function(suffix) {
return this.indexOf(suffix, this.length — suffix.length) !== -1;
};
Answer:

  1. This method determines whether or not a string ends with another string.
  2. This method determines whether or not a string begins with another string.
  3. This method returns the position of the last occurrence of a specified value in a string.
  4. This method returns the position of the first occurrence of a specified value in a string.

100.What will be the result of the following code?
document.getElementById(“banana”).className = document.getElementById(“banana”).className.replace(/(?:^|\s)apple(?!\S)/g ,’e’ );
Answer:

  1. Replace class ‘apple’ with ‘g’ in the HTML element which contains ID ‘banana’
  2. Replace current class with ‘apple’ in the HTML element which contains ID ‘banana’
  3. Replace class ‘apple’ with ‘e’ in the HTML element which contains ID ‘banana’
  4. Replace ID ‘apple’ with ‘banana’ in the HTML element which contains ID ‘banana’ and class ‘g’

101.Which of the following will determine if the user’s browser is named “Netscape”?

Answer:

  1. if(appName==”Netscape”){}
  2. if(document.appName==”Netscape”){}
  3. if(navigator==”Netscape”){}
  4. if(browser==”Netscape”){}
  5. None of these

102. Given a p element with some text content, which of the following code snippets sets the background color of the text to yellow, its color to red, and its font size to 20px?

Answer:

  1. var p = document.getElementById(elementId);
    p.setAttribute(«style», «background-color:yellow;color:red;font-size:20px;»);
  2. var p = document.getElementById(elementId);
    p.style.background = ‘yellow’;
    p.style.color= ‘red’;
    p.style.size= ’20px’;
  3. var p = document.getElementById(elementId);
    p.style.background = ‘yellow’;
    p.style.color= ‘red’;
    p.style.font.size= ’20px’;
  4. var p = document.getElementById(elementId);
    p.setAttribute(«style», «background-color:red;color:yellow;font-size:20;»);

103.Which of the following are not valid HTML events?

Answer:

  1. onmouseover
  2. onmouseout
  3. onmouseabove
  4. onmousedown
  5. onmousein

104.Which of the following options is used to access the attributes in E4X?

Answer:

  1. @
  2. ::
  3. #
  4. *

105.Which of the following can be used to write a JavaScript function that will accept user input?

Answer:

  1. The prompt method
  2. The alert method
  3. A form field
  4. All of these

106.Which of the following prints «AbBc»?

Answer:

  1. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  2. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  3. var b = ‘a’; var result = b.toUpperCase() + b + ‘b’.toUpperCase() +’C'[‘toLowerCase’](); alert(result);
  4. var b = ‘a’; var result = b.toUpperCase() + ‘b’ + ‘b’.toUpperCase() +C; alert(result);

107.Which of these options is the most maintainable way to attach JavaScript functionality to an HTML element?

Answer:

  1. <p onclick=»alert(‘You clicked me!’)»> some text </p>
  2. function fun(){alert(‘You clicked me!’)}
    <a onclick=fun()>…</a>
  3. function fun(){ alert(‘You clicked me!’); };
    var el = document.getElementById(«click-target»);
    el.onClick = fun;

    <a id=»click-target»>…</a>

  4. <a href=»javascript:alert(‘You clicked me!’)»>…</a>

108.Which of these options is the most maintainable way to attach JavaScript functionality to an HTML element?
<html>
<body>

function validate() {
var chk=»ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz»;
var ok=»yes»;
var temp;
var field1=document.getElementById(«t1»);
var field=field1.value.substring(field1.value.length-1,field1.value.length);
if(chk.indexOf(field)==»-1″) {
alert(«error»);
field1.value=(field1.value).slice(0,field1.value.length-1);
}
}

<input type=»text» id=»t1″ onkeyup=»validate()» onkeypress =»validate()»/>
</body>
</html>
Answer:

  1. The code will cause an error alert to be displayed if a numeric character is entered, and the numeric character is removed.
  2. The code will cause an error alert to be displayed if a non-numeric character is entered, and the non-numeric character is removed.
  3. The code will cause an error alert to be displayed if a numeric character is entered, and the value of textbox is reset.
  4. The code will cause an error alert to be displayed if a non-numeric character is entered, and the value of textbox is reset.

109. What would be the default setting for the expires attribute of the document.cookie property?

Answers:

  1. The duration of the browser session
  2. The duration the current document stays loaded
  3. Twenty-four hours from the time the cookie is set
  4. There is no default setting
  5. The duration for which the machine is on

110.Which of the following choices will remove a selection option from the code below?
<button id”newbtn” onclick=”g();”>Remove</button>
<select name=”selectBox” id=”selectBox”>
<option value=”option1″>option1</option>
<option value=”option2″>option2</option>
<option value=”option3″>option3</option>
<option value=”option4″>option4</option>
</select>
Answers:

  1. function g(){
    var index = 1;
    var d = document.getElementById(“selectBox”);
    var d_nested = d.childNodes[index];
    var throwawayNode = d.deleteChild(d_nested);
    }
  2. >
    function g(){
    var index = 1;
    var d = document.getElementById(“selectBox”);
    var d_nested = d.childNodes[index];
    var throwawayNode = d.clearChild(d_nested);
    }
  3. function g(){
    var index = 1;
    var d = document.getElementById(“selectBox”);
    var d_nested = d.childNodes[index];
    var throwawayNode = d.emptyChild(d_nested);
    }
  4. function g(){
    var index = 1;
    var d = document.getElementById(“selectBox”);
    var d_nested = d.childNodes[index];
    var throwawayNode = d.removeChild(d_nested);
    }

111.Which of the following is incorrect regarding Strict mode in JavaScript?

Answer:

  1. It catches some common coding errors, throwing exceptions.
  2. It enables features that are confusing or poorly thought out.
  3. It prevents, or throws errors, when relatively «unsafe» actions are taken (such as gaining access to the global object).

112. Which of the following is incorrect regarding Strict mode in JavaScript?
var a = ‘A’.charCodeAt(0) + 5;
var b = ‘c’.charCodeAt(0) + 1;
var c = 0;
for (var i = 0; i < 10; i++) {
c = c + (a+b % 2);
}
alert(c);

Answer:

  1. 700
  2. 60
  3. 0
  4. 760

113. Which of the following is/are true regarding JavaScript and multi-threading/concurrency?

Answer:

  1. JavaScript is single-threaded, forcing asynchronous events to a queue to wait for execution.
  2. JavaScript is multi-threaded, and behaves in a synchronous manner.
  3. JavaScript can be single or multi-threaded, depending on the browser’s capabilities.
  4. None of these.

114. Which of the following will change the color of the text box to green, as long as the user is pressing a key?

Answer:

  1. input type=»text» onkeydown=»color(‘white’)» onkeyup=»color(‘green’)» name=»txtName»
  2. input type=»text» onkeydown=»color(‘green’)» onkeyup=»color(‘white’)» name=»txtName»
  3. input type=»text» onkeydown=»color(‘green’)» name=»txtName»
  4. input type=»text» onkeydown=»color(‘white’)» name=»txtName»
  5. input type=»text» onkeypress=»color(‘green’)» onkeyup=»color(‘white’)» name=»txtName»

115. In an HTML page, the form tag is defined as follows:
<form onsubmit=»return Validate()»

action=»http://www.mysite.com/»>
The validate() function is intended to prevent the form from being submitted if the name field in the form is empty. What should the validate() function look like?

Answer:

  1. function Validate() { if(document.forms[0].name.value == «») return true; else return false; }
  2. function Validate() { if(document.forms[0].name.value == «») return false; else return true; }
  3. script type=»text/javascript»> function Validate() { if(document.forms[0].name== «») return false; else return true; } </script>
  4.   function Validate() { if(document.forms[0].name == «») return true; else return false; }

116. Which of the following statements are true regarding the code below?

alert(«foo» === new String(«foo»)); // output false

Answer:

  1. The «===» operator always returns false.
  2. The «===» operator returns true only if they refer to the same object (comparing by reference) and if both the primitive and the object have the same value.
  3. The «===» operator returns true only if the object (comparing by reference) and the primitive have the same value.
  4. The «===» operator does not work for objects.

117.Which of the following statements are true regarding the «this» keyword in JavaScript?

Answer:

  1. The value of «this» can be set by assignment during execution, and it will be the same each time the function is called.
  2. Inside a function, the value of «this» depends on how many times the function is called.
  3. Inside a function, the value of «this» depends on how the function is called (as a simple call, an object method, a constructor, etc.).
  4. In strict mode, the value of «this» may change from whatever it is set to, when entering the execution context.

118.Which of the following is not a correct way to empty the array a?

Answer:

  1. a = new Array();
  2. a = [];
  3. a.splice(0,a.length);
  4. a.clear()

119.Which of the following is the correct way to resize an iframe based on content?

Answer:

  1. function resizeIframe(height)
    {document.getElementById(‘frame_name_here’).height = parseInt(height)+60;}
    http://’src.htm’
  2. function resizeIframe(height)
    {document.getElementByName(‘frame_name_here’).height = parseInt(height)+60;}
    http://’src.htm’
  3. function resizeIframe(height)
    {document.getElementByDivId(‘frame_name_here’).height = parseInt(height)+60;}
    http://’src.htm’
  4. None of these

120.Which of the following is not a valid JavaScript function?

Answers:

  1. apply()
  2. call()
  3. toString()
  4. All the other options are valid.

121.What does the following code snippet do?

<input type=»radio»name=»r1″value=»radio1″onclick=»this.checked=false;alert(‘sorry’)»>

Answers:

  1. The code is invalid.
  2. The code makes it necessary for the user to select the radio button.
  3. The code disables the radio button.
  4. The code displays an alert when the user selects the button.

122.How can properties be added to an object class?

Answers:

  1. With the prototype() method
  2. With the prototype property
  3. It cannot be done.
  4. With the «this» object

123.Which of the following will correctly check if an object is an array?
Note: There may be more than one right answer.

Answers:

  1. Object.prototype.toString.call(arr) === ‘[object Array]’
  2. Object.isArray(arr)
  3. None of these
  4. With the «this» object

124.Which of the following check if an object has a specific property?

Answers:

  1. hasOwnProperty()
  2. hasProperty()
  3. It is browser-dependent
  4. None of these

125. Given the following window.open function:
window.open(url,name,»attributes»)
How can it be ensured that different URLs are opened in the same window?

Answers:

  1. The second attribute, name, should be the same.
  2. The name attribute should be null.
  3. The name attribute should be omitted.
  4. The name attribute should be different.
  5. None of these.

126.Which of the following code snippets renders a button invisible?

Answers:

  1. var button = document.getElementById(‘buttonId’);
    button.style.display=’none’
  2. var button = document.getElementById(‘buttonId’);
    button.style.display=’block’
  3. var button = document.getElementById(‘btn’);
    button.style.visibility=’false’;
  4. var button = document.getElementById(‘btn’);
    button.style.visibility=’disabled’;
  5. None of these.

127. Why does (0 < 5 < 3) return true?

Answers:

  1. Order of operations produces (true < 3), which returns true.
  2. Order of precedence produces (true < 3), which returns true.
  3. Order of operations produces (false < 3), which returns true.
  4. None of these.

128. What is the cleanest, most effective way to validate decimal numbers in JavaScript?

Answers:

  1. IsNumeric()
  2. isNaN()
  3. valid()
  4. isDecimal()

129. Which of the following is the best reason for not using «for…in» with array iteration?

Answers:

  1. for..in should be used to iterate over an array where index order is important.
  2. for..in should not be used to iterate over an array where index order is important.
  3. for…in loops iterate over non–enumerable properties.
  4. for…in loops do not iterate over enumerable properties.

130. Which of the following is the best reason for not using «for…in» with array iteration?

Answers:

  1. It forces the parser to treat the + sign as a part of an expression.
  2. The + sign is used as a cast operator.
  3. It is used to denote a type of object in JavaScript.
  4. None of these.

131.Which of the following will implement a singleton pattern in JavaScript?

Answers:

  1. var anObject = {
    method1: function () {
    // …},

    method2: function () {
    // …
    }
    };
    >
  2. function method1(){
    // …
    }
    function method2(){
    // …
    }
  3. var method1 = function(){
    // …
    }
    var method2 = function(){
    // …
    }
  4. var method1;
    var method2;

132. Which of the following code snippets will correctly detect a touchscreen device?

Answers:

  1. function isTouchDevice() {
    return !!(‘ontouchstart’ in window) || !!(‘onmsgesturechange’ in window);
    };
  2. function isTouchDevice() {
    try {
    document.body.createEvent(«TouchEvent»);
    return true;
    } catch (e) {
    return false;
    }
    }
  3. function isTouchDevice(){
    return (typeof(navigator.ontouchstart) != ‘undefined’) ? true : false;
    }
  4. function isTouchDevice(){
    return (navigator.msMaxTouchPoints == 0);
    }

133. Which of the following shows examples of valid auto increment/decrement loops?

Answers:

  1. for(var i=0; i < 100; i++){} for(var i=0; i > -100; i—){}
  2. for(var i=0; i < 100; i+){} for(var i=0; i > -100; i-){}
  3. for(var i=0; i > 100; i++){}
    for(var i=0; i < -100; i—){}
  4. for(var i=0; i > 100; i+){}
    for(var i=0; i < -100; i-){}

134. Analyze the following code snippet. What will be the output of this code?
<html>
<body>

var str = «The drain of the plane is plain»;
var patt1 =/ain/g;
document.write(str.match(patt1));

</body>
</html>
Answers:

  1. a
  2. ain
  3. 7,29
  4. 7
  5. ain,ain

135.The following are sample codes on how to merge properties of two JavaScript objects dynamically:
var obj1 = { food: ‘pizza’, car: ‘ford’ }
var obj2 = { animal: ‘dog’ }
Which of the following are JavaScript codes?

Answer:

  1. obj1.merge(obj2);
  2. function MergeRecursive(obj1,obj2){
    var obj3 = {};
    for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
    for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
    return obj3;
    }
  3. function MergeRecursive(obj1, obj2) {
    for (var p in obj2) {
    try {
    // Property in destination object set; update its value.
    if ( obj2[p].constructor==Object ) {
    obj1[p] = MergeRecursive(obj1[p], obj2[p]);
    } else {
    obj1[p] = obj2[p];
    }
    } catch(e) {
    // Property in destination object not set; create it and set its value.
    obj1[p] = obj2[p];}
    }
    return obj1;
    }
  4. Object.extend = function(destination,source) {
    for (var property in source)
    destination[property] = source[property];
    return destination;
    }
    obj1.extend(obj2)

136.You need to be able to determine which page of the web site has been the most recently modified. Which object would enable you to do this?

Answers:

  1. document
  2. window
  3. history
  4. browser
  5. form
  6. location

137.Which of the following are the valid JavaScript codes to obtain the number of milliseconds since the epoch?
Note: There may be more than one right answer.

Answers:

  1. var timestamp = new Date().getTime();
  2. var timestamp = Number(new Date());
  3. var timestamp = Date.now;
  4. var timestamp = new Date().valueOf();

138.Which of the following ‘if’ statements is correctly used to get the size of both ‘variable1’ and ‘variable2’ objects?
var variable1 = {‘name’:’theName’, ‘address’:’theAddress’,’age’: ’18’}
var variable2 = [‘theName’,’theAddress’,’18’];

variable1[«name»] = «theName2»;
variable1[«name»] = «theName3»;
variable1[«name2»] = «theName4»;
variable1[«name2»] = «theName5»;

Object.size = function(importer) {
var exporter = 0, key;
for (key in importer) {
if (importer.hasOwnProperty(key)) exporter++;
}
return exporter;
};

Answers:

  1. if(typeof(variable1)==’object’ && typeof(variable2)==’array’){
    Object.size(variable1);
    variable2.length;
    }
  2. if(typeof(variable1)==’array’ && typeof(variable2)==’object’){
    Object.size(variable1);
    variable2.length;
    }
  3. if(typeof(variable1) > typeof(variable2)){
    Object.size(variable1);
    variable2.length;
    }
  4. if(typeof(variable1) == typeof(variable2)){
    Object.size(variable1);
    variable2.length;
    }

139.Consider the following JavaScript arrays:
var a = [1, 2];
var b = [3, 4, 5];
Which of the following will append the contents of array «b» to array «a»?

Answers:

  1. a.push(b);
  2. a.splice(0,0,b);
  3. a = b.concat(a);
  4. a.join(b);

140.How can it be determined if JavaScript is disabled in the user’s browser?

Answers:

  1. It is browser-dependent.
  2. There is no way to detect if JavaScript is disabled.
  3. Use the HTML<noscript> tag to display different content if JavaScript is disabled.
  4. None of these.

141.Which of the following choices shows the correct result for the code below? var arr = []; arr[0] = «Jani»; arr[1] = «Hege»; arr[2] = «Stale»; arr[3] = «Kai Jim»; arr[4] = «Borge»; console.log(arr.join()); arr.splice(2, 0, «Lene»); console.log(arr.join());

Answers:

  1. Jani,Hege,Stale,Kai Jim,Borge
    Lene,Jani,Hege,Stale,Kai Jim,Borge
  2. Jani,Hege,Stale,Kai Jim,Borge
    Jani,Hege,Lene,Stale,Kai Jim,Borge
  3. Jani,Hege,Stale,Kai Jim,Borge
    Jani,Hege,Stale,Kai Jim,Lene,Borge
  4. Jani,Hege,Stale,Kai Jim,Borge
    Jani,Hege,Stale,Kai Jim,Borge

142. Consider the following scenario:
The document.write() method is embedded to write some text within a pair of 

table tags. Upon loading the file, however, garbled text appears on the section of the page where the text should be. What could be the reason for this?

Answers:

  1. The browser does not support JavaScript.
  2. An older version of the browser is being used.
  3. The browser does not support cookies.

143. What is the output of the following code?
var a = 5;
var b = 1;
if(!!»false») {
a = a + 5;
b = 3;
};
if(!!0) {
a = a + 5;
b = b + 2;
};
alert(a+b);

Answers:

  1. 20
  2. 6
  3. None of these

144.Consider the following code:
var vNew=new Date()
Which of the following options will return true?

Answers:

  1. vNew instanceof boolean
  2. vNew instanceof boolean
  3. vNew instanceof Date
  4. All of these

145.Which of the following will detect if the browser supports a certain CSS property?

Answers:

  1. typeof document.body.style.borderRadius == ‘string’
  2. typeof document.body.style.borderRadius == ‘undefined’
  3. typeof document.body.style.borderRadius == true
  4. It is impossible.

146.Which of the following is not a valid code for redirect to stackoverflow.com?
Note: There may be more than one right answer.

Answers:

  1. window.location.href = «http://stackoverflow.com»;
  2. window.location.href («http://stackoverflow.com»);
  3. window.location.replace=»http://stackoverflow.com»;
  4. window.location.replace(«http://stackoverflow.com»);

147.The following statements show two ways of calling a JavaScript function:
i)onclick = «a();»
ii)onclick=»JavaScript:a();»
Which of the following options is correct, with regard to the two statements above?

Answers:

  1. There is no difference between the two statements
  2. The first statement is incorrect and the second one is correct.
  3. The first statement is correct and the second statement is incorrect.

148.Which of the following code snippets will trigger an input type=»file» attribute when an element with a «newbtn» ID is clicked?

Answers:
<button id»newbtn» onclick=»grt();»>Upload</button>
<form>
<input id=»thisId» type=»file» name=»upload» />
</form>
</form>

  1. function grt(){document.getElementById(‘thisId’).keypress();}
  2. function grt(){document.getElementById(‘thisId’).load();}
  3. function grt(){document.getElementById(‘thisId’).dblclick();}
  4. function grt(){document.getElementById(‘thisId’).click();}

149.Which of the following JavaScript code snippets is the more efficient and why?
Code Snippet 1

for(i=0;i
Code Snippet 2

var theimages = document.images;
for(i=0;i

Answers:

  1. Both codes are equally efficient.
  2. The first code is more efficient because it contains less code.
  3. The first code is more efficient because it employs object caching.
  4. The second code is more efficient because it employs object caching.

150.Which of the following cope samples will correctly search for the word «for» in a string?
Note: There may be more than one right answer.

Answers:

  1. var str=»This is test for javascript search !!!»;
    if(str.search(«for») != -1) {
    alert(«true»);
    }
    else {
    alert(«false»);
    }
  2. var str=»This is test for javascript search !!!»;
    if(str.indexof(«for») != -1) {
    alert(«true»);
    }
    else {
    alert(«false»);
    }
  3. var str=»This is test for javascript search !!!»;
    if(str.indexOf(«for») != -1) {
    alert(«true»);
    }
    else {
    alert(«false»);
    }
  4. var str=»This is test for javascript search !!!»;
    if(str.contains(«for») != -1) {
    alert(«true»);
    }
    else {
    alert(«false»);
    }

151.Given two frames Frame1 and Frame2, where Frame2 has a div element with id «some», how can the div element’s color be changed in Frame2, using JavaScript code in Frame1?

Answers:

  1. var div = top.Frame2.document.getElementById(‘some’);
    div.style.color= «orange»;
  2. var div = document.getElementById(‘some’);
    div.style.color= «orange»;
  3. var div = top.Frame1.document.getElementById(‘some’);
    div.style.color= «orange»;
  4. None of these.

152.Which of the following JavaScript Regular Expression character classes finds any non-digit character in a given string?

Answers:

  1. \W
  2. \S
  3. \B
  4. \D

153. Which best describes void?

Answers:

  1. A method
  2. A function
  3. A statement
  4. An operator
  5. A built-in object

154.Which of the following is used to solve the problem of enumerations in JavaScript?

Answers:

  1. let
  2. Regex
  3. Generators
  4. E4X

155.Which of the following cannot be achieved using JavaScript?
Note: There may be more than one right answer.

Answers:

  1. Read or write from external files (except .js files)
  2. Access or modify browser settings
  3. Launch client processes (eg windows applications)
  4. Launching the default email application of the client

156.The following are sample codes on how to loop through JavaScript object literals with objects as members:
var validation_messages = {
«key_1»: {
«your_name»: «jimmy»,
«your_msg»: «hello world»
},
«key_2»: {
«your_name»: «billy»,
«your_msg»: «foo equals bar»
}
}
Which of the following are invalid native JavaScript codes?
Note: There may be more than one right answer.

Answers:

  1. for (var key in validation_messages) {
    var obj = validation_messages[key];
    for (var prop in obj) {
    alert(prop + » = » + obj[prop]);
    }
    }
  2. Object.keys(validation_messages).forEach(function(key) {
    var obj = validation_messages[key];
    Object.keys(obj).forEach(function(key) {
    alert (prop + “ = “ + obj[key]);
    )};
  3. (validation_messages.hasOwnProperty(key)) {
    var obj = validation_messages[key];
    for (var prop in obj) {
    if (obj.hasOwnProperty(prop)) {
    alert(prop + “ = “ + obj[prop]);
    }
    }
    }
    }
  4. _.each(validation_messages, function(value, key){
    _.each(value, function(value, key){
    alert(prop + » = » + value);
    });
    });

157.Analyze the following code snippet. What will be the output of this code?
html>
<body>

var str = «Visit Gardens(now)»;
var patt1 = new RegExp(«(now)», «g»);
patt1.test(str);
document.write(RegExp.lastParen);

</body>
</html>
Answers:

  1. now
  2. (now)
  3. 15
  4. 19

158.Consider the following code:
var variable=2*2+10000/10-133%5;
Which of the following combinations have the lowest operator precedence in «variable»?

Answers:

  1. «*» and «+»
  2. «/» and «%»
  3. «/» and «+»
  4. «*» and «%»

159.While coding a loop, you come across a condition where you have to terminate the loop and continue with the statements following the loop. Which statement would you use?

Answers:

  1. exit
  2. return
  3. continue
  4. while
  5. break

160. What is the best way to make optional parameters of functions?

Answers:

  1. function someFunction(requiredArg, optionalArg) {
    optionalArg = optionalArg || ‘defaultValue’;
    alert(optionalArg);
    }
  2. function someFunction(requiredArg, optionalArg) {
    optionalArg = (typeof optionalArg === «undefined») ? «defaultValue» : optionalArg;
    alert(optionalArg);
    }
  3. function someFunction(requiredArg, optionalArg) {
    optionalArg = (optionalArg === «undefined») ? «defaultValue» : optionalArg;
    alert(optionalArg);
  4. All of these

161. Which of the following are correct closure functions?

Answers:

  1. function foo(x) {
    var tmp = 3;
    return function (y) {
    alert(x + y + (++tmp));
    }
    }
    var bar = foo(2); // bar is now a closure.
    bar(10);
  2. function foo(x) {
    var tmp = 3;
    function bar(y) {
    alert(x + y + (++tmp));
    }
    bar(10);
    }
    foo(2)
  3. function foo(x) {
    var tmp = 3;
    function bar(y) {
    function bar1(tmp) {
    alert(x + y + (++tmp));
    }
    }
    bar(10);
    }
    foo(2)
  4. function foo(x) {
    var tmp = 3;
    return function (y) {
    alert(x + y + tmp);
    x.memb = x.memb ? x.memb + 1 : 1;
    alert(x.memb);
    }
    }
    var age = new Number(2);
    var bar = foo(age); // bar is now a closure referencing age.
    bar(10);

162.Which of the following will correctly detect browser language preference?

Answers:

        1. var language = window.navigator.userLanguage || window.navigator.language;
          alert(language);
        2. var language = navigator.browserLanguage || window.navigator.language;
          alert(language);
        3. var language =navigator.userLanguage;
          alert(language);
        4. var language = window.navigator.language;
          alert(language);

163.What is the output of the following code?
var container = {
someKey: 3,
someOtherKey: “someObject”,
anotherKey: “Some text”
};
if (“someOtherKey” in container) {
alert (true);
}
delete container [“someOtherKey”];
if (container[“someOtherKey”] === null) {
alert (false);
}
if (container[“someOtherKey”] === undefined) {
alert (true);
}
if (container.someOtherKey === undefined) {
alert (false);
}
if (container.someOtherKey === undefined) {
alert (true);
}
delete container[“someKey”];
if (container.someKey === 3) {
alert (true);
}
Answers:

        1. true
          true
          false
        2. true
          true
          true
        3. true
          false
          true
          false
          true
          true
        4. true
          true
          false
          true

164. Which of the following is a good reason why JavaScript variables would start with a dollar sign ($)?

Answers:

        1. $ is a prefix used to create a instance of a object.
        2. $ is a keyword in JavaScript.
        3. $ is used to quickly identify and parse variables
        4. None of these

165.Which of the following code is correct for validating date values?
Note: There may be more than one right answer.

Answers:

        1. var d = Date.parse(‘foo’);
          if (isNaN(d)==false)
          {
          alert(new Date(d));
          } else {
          alert(‘Invalid date’);
          }
        2. var d = new Date(‘foo’);
          if (d instanceof Date && isFinite(d))
          {
          alert(d);
          } else {
          alert(‘Invalid date’);
          }
        3. Date.prototype.valid = function() {
          return isFinite(this);
          }
          var d = new Date(‘foo’);
          if (d.valid())
          {
          alert(d);
          } else {
          alert(‘Invalid date’);
          }
        4. All of the above

166. Which of the following correctly explains the difference between a «for…in» and a «for» loop?

Answers:

        1. «for…in» has two expressions. It iterates over the enumerable properties of an object, in an arbitrary order, for each distinct property, statements can be executed. This should not be used to iterate over an array where index order is important.
          «for» consists of three optional expressions enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
        2. «for…in» has three expressions. It iterates over the enumerable properties of an object, in an arbitrary order, for each distinct property, statements can be executed. This should not be used to iterate over an array where index order is important.
          «for» consists of four optional expressions enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
        3. «for…in» iterates over the enumerable properties of an object, in an arbitrary order, for each distinct property, statements can be executed. This should be used to iterate over an array where index order is important.
          «for» consists of three optional expressions enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
        4. «for…in» iterates over the enumerable properties of an object, in arbitrary order, for each distinct property, statements can be executed, this should be used to iterate over an array where index order is important.
          «for» consists of two optional expressions enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.

167.Which of the following will list the properties of a JavaScript object?

Answers:

  1. var keys = Object.keys(myJsonObject);
  2. var keys = Object.value(myJsonObject)
  3. var keys = Object.keys(myJsonValue)
  4. None of these

168.Consider the following image definition:
<img id=»logo» src=»companylogo1.gif» height=»12″ width=»12″ >
Which of the following will change the image to companylogo2.gif when the page loads?

Answers:

  1. logo.source=»companylogo2.gif»
  2. logo.source=»companylogo1.gif»
  3. document.getElementById(‘logo’).src=»companylogo1.gif»v
  4. document.getElementById(‘logo’).src=»companylogo2.gif»

169.Which of the following objects in JavaScript contains the collection called «plugins»?

Answers:

  1. Location
  2. Window
  3. Screen
  4. Navigator

170.Which of following uses the «with» statement in JavaScript correctly?

Answers:

  1. with (document.getElementById(«blah»).style) { background = «black»; color = «blue»; border = «1px solid green»; }
  2. with document.getElementById(«blah»).style background = «black»; color = «blue»; border = «1px solid green»; End With
  3. With document.getElementByName(«blah»).style background = «black»; color = «blue»; border = «1px solid green»; End With
  4. with (document.getElementById(«blah»).style) { .background = «black»; .color = «blue»; .border = «1px solid green»; }

171.Which of the following is the best way to show both single and double quotes in the same sentence?

Answers:

  1. alert(«It’s «+’»game»‘+» time.»);
  2. alert(‘It\’s \»game\» time.’);
  3. alert(‘It\’\s «game» time.’);
  4. alert(‘It\’s «game» time.’);

172.Which of the following code snippets shows an alert for an empty string?

Answers:

  1. If(a){ alert(‘This is empty string’);}
  2. If(a == NUL){ alert(‘This is empty string’);}
  3. If(!a){ alert(‘This is empty string’);}
  4. If(a.empty){ alert(‘This is empty string’);}

173.Which of the following code snippets shows an alert for an empty string?

Answers:

  1. var str = ‘something — something_else’; var substrn = str.split(‘ — ‘);
  2. var str = ‘something — something_else’; var substrn = split.str(‘ — ‘);
  3. var str = ‘something — something_else’; var substrn = str.split(‘ — ‘,’ — ‘);
  4. var str = ‘something — something_else’; var substrn = split.str(‘ — ‘,’ — ‘);

174.Which of the following choices will detect if «variableName» declares a function?

var variableName= function(){};

Answers:

  1. return variableName;
  2. nameof variableName;
  3. isFunction variableName;
  4. typeof variableName;

175. Which of the following choices will change the source of the image to «image2.gif» when a user clicks on the image?

Answers:

  1. img id=»imageID» src=»image1.gif» width=»50″ height=»60″ onmousedown=»changeimg(image1.gif)» onmouseup=»changeimg(image2.gif)»
  2. img id=»imageID» src=»image1.gif» width=»50″ height=»60″ onmouseclick=»changeimg(image2.gif)» onmouseup=»changeimg(image1.gif)»
  3. img id=»imageID» src=»image2.gif» width=»50″ height=»60″ onmousedown=»changeimg(image1.gif)» onmouseup=»changeimg(image2.gif)»
  4. img id=»imageID» src=»image2.gif» width=»50″ height=»60″ onmousedown=»changeimg(image2.gif)» onmouseup=»changeimg(image1.gif)»
  5. img id=»imageID» src=»image1.gif» width=»50″ height=»60″ onmousedown=»changeimg(‘image2.gif’)» onmouseup=»changeimg(‘image1.gif’)»

176.Which of the following best describes a «for» loop?

Answers:

  1. «for» loop consists of six optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
  2. «for» loop consists of five optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
  3. «for» loop consists of four optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
  4. «for» loop consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.

177.An HTML form contains 10 checkboxes all named «chkItems». Which JavaScript function can be used for checking all the checkboxes together?

Answers:

  1. function CheckAll() { for (z = 0; z < document.forms.chkItems.length; z++) { document.forms.chkItems[z].checked=true } }
  2. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems[z].checked=true } }
  3. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems.list[z].checked=true } }
  4. function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems.list[z].checked=false } }

178. Consider the following JavaScript function to change the color of the text box named txtName:
function color(col) { document.forms[0].txtName.style.background=col }
Which of the following will change the color of the text box to green, as long as the user is pressing a key?
Answers:

  1. input type=»text» onkeydown=»color(‘white’)» onkeyup=»color(‘green’)» name=»txtName»
  2. input type=»text» onkeydown=»color(‘green’)» onkeyup=»color(‘white’)» name=»txtName»
  3. input type=»text» onkeydown=»color(‘green’)» name=»txtName»
  4. input type=»text» onkeydown=»color(‘white’)» name=»txtName»
  5. input type=»text» onkeypress=»color(‘green’)» onkeyup=»color(‘white’)» name=»txtName»

179.Which of the following code snippets returns «[object object]»?

Answers:

  1. var o = new Object(); o.toSource();
  2. var o = new Object(); o.valueOf();
  3. var o = new Object(); o.toString();
  4. var o = new Object(); o.getName(); <

180.In an HTML page, the form tag is defined as follows:
<form onsubmit=»return Validate()» action=»http://www.mysite.com/»>
The validate() function is intended to prevent the form from being submitted if the name field in the form is empty. What should the validate() function look like?

Answers:

  1. function Validate() { if(document.forms[0].name.value == «») return true; else return false; }
  2. function Validate() { if(document.forms[0].name.value == «») return false; else return true; }
  3. function Validate() { if(document.forms[0].name== «») return false; else return true; }
  4. function Validate() { if(document.forms[0].name == «») return true; else return false; }

181.Which of the following results is returned by the JavaScript operator «typeof» for the keyword «null»?

Answers:

  1. function
  2. object
  3. string
  4. number

182.What will be the final value of the variable «apt»?
var apt=2;
apt=apt<<2;

Answers:

  1. 2
  2. 4
  3. 6
  4. 16

183.Consider three variables:
someText = ‘JavaScript1.2’;
pattern = /(\w+)(\d)\.(\d)/i;
outCome = pattern.exec(someText);
What does pattern.global contain?
Answers:

  1. true
  2. false
  3. undefined
  4. null
  5. 1

184.What does the + sign in front of a function name mean in JavaScript?

Answers:

  1. It forces the parser to treat the + sign as a part of an expression.
  2. The + sign is used as a cast operator.
  3. It is used to denote a type of object in JavaScript.
  4. None of these.

185.Consider the following scenario:
The document.write() method is embedded to write some text within a pair of <td></td> table tags. Upon loading the file, however, garbled text appears on the section of the page where the text should be. What could be the reason for this?

Answers:

  1. The browser does not support JavaScript.
  2. An older version of the browser is being used..
  3. The browser does not support cookies.

186.Consider the following code:
var vNew=new Date()
Which of the following options will return true?

Answers:

  1. vNew instanceof boolean
  2. vNew instanceof object
  3. vNew instanceof Date
  4. All of these

187.The following statements show two ways of calling a JavaScript function:
i)onclick = «a();»
ii)onclick=»JavaScript:a();»
Which of the following options is correct, with regard to the two statements above?

Answers:

  1. There is no difference between the two statements.
  2. The first statement is incorrect and the second one is correct.
  3. vNew instanceof Date
  4. The first statement is correct and the second statement is incorrect.

188.Choose another way to write x ? a = b : a = c

Answers:

  1. if (‘x’) { a = b; } else { a = c; }
  2. if (x) { a = c; } else { a = b; }
  3. x : a = c ? a =
  4. None of above

189.What value would JavaScript assign to an unitialized variable?

Answers:

  1. Nan
  2. null
  3. undefined
  4. false

190.What is the difference between setTimeout and setInterval in JavaScript?

Answers:

  1. setInterval executes a function or code snippet a certain amount of time after setInterval() is called, while setTimeout executes a function or code snippet a certain amount of time after the previous timeout fired.
  2. setTimeout executes a function or code snippet a certain amount of time after setTimeout() is called, while setInterval executes a function or code snippet a certain amount of time after the previous interval fired.
  3. setTimeout() triggers only once, while setInterval() triggers repeatedly
  4. There is no difference between setTimeout() and setInterval().

191.What will be the output of this code?
parseInt(1 / 0, 19);

Answers:

  1. 1
  2. 0
  3. 20
  4. 18

192.What will the function NaN return for the condition NaN == NaN?

Answers:

  1. true
  2. false
  3. error
  4. 0

193.What is the output of following charsets in javascript?
++[[]][+[]]+[+[]]

Answers:

  1. 0
  2. 10
  3. 100
  4. 1000

194.While coding a loop, which statement can be used to ignore the rest of the statements, and continue with the beginning of the loop?

Answers:

  1. exit
  2. return
  3. continue
  4. while
  5. break

195.Which of the following code samples prints false?

Answers:

  1. var n = 3.2;
    alert(n===+n && n!==(n|0));
  2. var n = 3;
    alert(n===+n && n===(n|0));
  3. var boolValue = new Boolean(«false»);
    alert(boolValue);
  4. var n=3.2;
    alert(n % 1 === 0);

196.The statement navigator.platform indicates ‘Win16’ on user’s computer that’s running Windows NT. Which of the following is true?

Answers:

  1. navigator.platform is supposed to show ‘Win16’ on Windows NT.
  2. The userAgent property reflects the correct operating system.
  3. The property can be modified.
  4. navigator.platform shows the operating system for which the browser was compiled for.
  5. The browser version is outdated.

197. How can GUIDs/UUIDs be created in JavaScript?

Answers:

  1. GUIDs/UUIDs cannot be created in JavaScript.
  2. The userAgent property reflects the correct operating system.
  3. There is no specific method to create GUIDs/UUIDs, but it’s possible to generate GUID-like random numbers in JavaScript.
  4. JavaScript has methods only for generating GUIDs/UUIDs with only capital letters.
  5. JavaScript has methods for creating and automatically changing GUIDs/UUIDs.

198. Which of the following is the correct method to use, in order to know the name of both the Object and Object Class in JavaScript?

Answers:

  1. toSource()
  2. valueOf()
  3. toString()
  4. getName()

199. How does the keyword work within a JavaScript object literal?

Answers:

  1. var foo = {};
    foo.someMethod = function(){
    alert(this);
    }
  2. someMethod = function(){
    alert(this);
    }
  3. var foo = {};
    someMethod.foo = function(){
    alert(this);
    }
  4. var foo = {};
    someMethod = function(foo){
    alert(this);
    }

200. <a href=’http://w3.org/’ onclick=’someFunc(); return false;’>Click here!</a >
What does «return false» do to this onclick event?

Answers:

  1. It prevents the default browser behavior from taking place alongside someFunc().
  2. It prevents someFunc() to run from a second click.
  3. It prevents someFunc() from returning any values.
  4. None of the above.

201.Which of the following is the best way of retrieving DOM elements using CSS class names?

Answers:

  1. var className = ‘someClassName’;
    var retrievedElements= [];
    var myclass = new RegExp(‘\\b’+className+’\\b’);
    var elem = this.getElementsByTagName(‘*’);
    for (var i = 0; i < elem.length; i++) { var classes = elem[i].className; if (myclass.test(classes)) retrievedElements.push(elem[i]); }
  2. var className = ‘someClassName’;
    var retrievedElements= document.getElementsByClassName(className);
  3. var className = ‘someClassName’;
    var retrievedElements= [];
    var elem = this.getElementsByTagName(‘*’);
    for (var i = 0; i < elem.length; i++) { var classes = elem[i].className; if (className.indexOf(classes) == 0) retrievedElements.push(elem[i]); }
  4. It is not possible to retrieve DOM elements using CSS class names.

202.What is the correct code snippet to change image source?

Answers:

  1. document.getElementById(«imgageId»).src = «newImage.png»;
  2. document.getElementById(«imgageId»).longdesc = «newImage.png»;
  3. document.getElementById(«imgageId»).href = «newImage.png»;
  4. document.getElementById(«imgageId») = «newImage.png»;

203.When toggling a variable, its cycle must be 0 and 1. When the variable’s active value is 0, the next value should be 1, and when the variable’s active value is 1, the next value should be 0.

Considering the scenario above, which of the following is correct?

Answers:

  1. q = (q == 1 ? 1 : 0);
  2. q = 1 — q;
  3. q ^= 0;
  4. q = inv(0);

204. Given a TextArea element with ID «text», which will disable the resizable property of the TextArea?

Answers:

  1. document.getElementById(«text»).style.resize = «none»;
  2. document.getElementById(«text»).style.resize = «disabled»;
  3. document.getElementById(«text»).resize = «none»;
  4. document.getElementById(«text»).resize = «disabled»;

205. Which method evaluates a string of JavaScript code in the context of the specified object?

Answers:

  1. parseInt
  2. Eval
  3. parseFloat
  4. Efloat

206. Which of the following will include a JavaScript file in another JavaScript file?

Answers:

  1. Adding a script tag with the script URL in the HTML
  2. Loading it with an AJAX call then using eval
  3. Using ‘import’ operator
  4. Using ‘include’ operator

207. Suppose you receive url of mp3 from server to play it right away. How would you implement this code snippet?

Answers:

  1. var audio = new Audio();
    audio.play();
  2. var audio = new Audio(url);
    audio.play();
  3. var audio = new Audio(url);
    audio.load();
  4. var audio = new Audio();
    audio.setAttribute(«href», url);
    audio.load();
    audio.play();

208.Which of the following is the correct way to stop setInterval() from calling a function in JavaScript?

Answers:

  1. setInterval() returns an interval ID, which can pass to clearInterval() to stop it from calling its designated function.
  2. Cannot stop the setInterval() from calling its designated function.
  3. var audio = new Audio(url);
    audio.load();
  4. Stopping setInterval() is browser-dependent; some browsers support stopping setInterval(), others don’t.
  5. None of these.

209.Which of the following code samples is correct?

Answers:

  1. var param1 = encodeURIComponent(«http://xyz.com/?a=1&b=2»);
    var param2 = encodeURIComponent(«http://abc.com/?a=2&b=5»);
    var url = «http://test.odesk.com/file name.html?param1=» + param1 + «&param2=» + param2;
    location.href = encodeURI(url);
  2. var param1 = encodeURIComponent(«http://xyz.com/?a=1&b=2»);
    var param2 = encodeURIComponent(«http://abc.com/?a=2&b=5»);
    var url = «http://test.odesk.com/file name.html?param1=» + param1 + «&param2=» + param2;
    location.href = url;
  3. var param1 = encodeURI(«http://xyz.com/?a=1&b=2»);
    var param2 = encodeURI(«http://abc.com/?a=2&b=5»);
    var url = «http://test.odesk.com/file name.html?param1=» + param1 + «&param2=» + param2;
    location.href = encodeURIComponent(url);
  4. var param1 = encodeURIComponent(«http://xyz.com/?a=1&b=2»);
    var param2 = encodeURIComponent(«http://abc.com/?a=2&b=5»);
    var url = «http://test.odesk.com/file name.html?param1=» + param1 + «&param2=» + param2;
    href.location = encodeURI(url);

210.Which of the following statements about the ‘new’ keyword is incorrect?

Answers:

  1. It creates a new object.
  2. It sets the constructor property of the object to ‘Object’.
  3. var audio = new Audio(url);
    audio.load();
  4. It prevents any user-defined function from being called as a constructor.
  5. It executes a constructor function.

211.How can you calculate the number of arguments received by the function?

Answers:

  1. Using arguments.length
  2. Using args.length.
  3. Using count(arguments)
  4. Can not be determined

212. Which of the following statements are true regarding «window.onload» and «»?

Answers:

  1. There is no difference between «window.onload» and «», and there is no general preference between the two, as far as best practices is concerned.
  2. «window.onload» and «» are functionally equivalent, but «» is preferred because it combines the JavaScript code with the HTML markup.
  3. «window.onload» and «» are functionally equivalent, but «window.onload» is preferred because it separates the JavaScript code from the HTML markup.
  4. None of the above.

213. The following codes are for comparing equality operators «==» and «===» in JavaScript.
Which of the following are the correct results?

Answers:

  1. var a = «12» + «3»;
    var b = «123»;
    return (a === b);
    result: true
  2. var a = [1,2,3];
    var b = [1,2,3];
    return (a == b);
    result: false
  3. var a = new String(«123»);
    var b = «123»;
    return (a === b);
    result: true/li>
  4. var a = { x: 1, y: 2 };
    var b = { x: 1, y: 2 };
    return (a == b);
    result: true.

214. Which of the following code prints false?

Answers:

  1. var boolValue = new Boolean(«false»);
    alert(boolValue);
  2. var boolValue = new Boolean();
    alert(boolValue); var boolValue = new Boolean();
    alert(boolValue);
  3. var boolValue = String(«false») == «false»;
    alert(boolValue);
  4. var boolValue = «false»;
    alert(!!boolValue);

215. Which of the following code prints false?

Answers:

  1. var boolValue = new Boolean(«false»);
    alert(boolValue);
  2. var boolValue = new Boolean();
    alert(boolValue); var boolValue = new Boolean();
    alert(boolValue);
  3. var boolValue = String(«false») == «false»;
    alert(boolValue);
  4. var boolValue = «false»;
    alert(!!boolValue);

216. Which of the following statements are correct about null and undefined?

Answers:

  1. Undefined indicates that a variable has not been assigned a value. Null can be assigned to a variable as a representation of no value.
  2. Both undefined and null indicate that a variable has not been assigned a value.
  3. Null is a primitive value used when a variable has not been assigned a value. Undefined is a primitive value that represents an empty or non-existent reference.
  4. None of these.

217. Which of the following will include a CSS style sheet in page, after an event has occurred?

Answers:

  1. document.write();
  2. document.createStyleSheet(‘somestyle.css’);
  3. var styles = «@import url(‘somestyle.css ‘);»;
    var newSS = document.createElement(‘link’);
    newSS.rel = ‘stylesheet’;
    newSS.href = ‘data:text/css,’ + escape(styles);
  4. None of these.

218.Which of the following statements regarding prototypes in JavaScript is not correct?

Answers:

  1. document.write();
  2. document.createStyleSheet(‘somestyle.css’);
  3. var styles = «@import url(‘somestyle.css ‘);»;
    var newSS = document.createElement(‘link’);
    newSS.rel = ‘stylesheet’;
    newSS.href = ‘data:text/css,’ + escape(styles);
  4. None of these.

219.Which of the following statements regarding prototypes in JavaScript is not correct?

Answers:

  1. The prototype property allows you to add properties and methods to an object.
  2. The prototype property is initially an empty object, and can have members added to it.
  3. Every object has a prototype by default.
  4. Prototype does not have a prototype.

220.Which of the following statements is incorrect regarding SVG

Answers:

  1. SVG stands for Scalable Vector Graphics.
  2. SVG graphics do NOT lose any quality if they are zoomed or resized.
  3. SVG images can be searched, indexed, scripted, and compressed.
  4. SVG is a W3C recommendation

221.Suppose you have a circle element of SVG element. How to draw black border with width 10px for this circle element?

Answers:

  1. circle.setAttribute( “stroke”, “#000000”);
    circle.setAttribute( “stroke-width”, “10”);
  2. circle.setAttribute( “border-color”, “#000000”);
    circle.setAttribute( “border-width”, “10”);
  3. circle.setAttribute( “border”, “#000000; 10”);
  4. circle.setAttribute( “stroke”, “#000000 10”);

222.What is the correct format for adding comments to a JSON file

Answers:

  1. /* comment */
  2. Comments aren’t allowed inside JSON files.

223.What is the correct format for adding comments to a JSON file

Answers:

  1. /* comment */
  2. <!— comment —>
  3. <? comment ?>
  4. Comments aren’t allowed inside JSON files.

224. How can you get the type of arguments passed to a function?

Answers:

  1. using typeof operator
  2. using getType function
  3. Both of the above.
  4. None of the above.

225. Which operator creates a new object from the specified object type?

Answers:

  1. obj
  2. create
  3. new
  4. None of the above.

226. Which of the following variable examples is/are undefined?

Answers:

  1. var a;
  2. var a = “undefined”;
  3. var a = undefined;
  4. All of the above

227. How many type(s) of storage HTML5 supports?

Answers:

  • 1
  • 2
  • 3
  • 4

228. Which of the following code snippets sets cookie correctly?

Answers:

  1. document.cookie = «username=John;password=John#1»;
  2. document.cookie = «username:John;password:John#1»;
  3. document.cookie(«username=John;password=John#1»);
  4. document.cookie = «username=John password=John#1»;

229. Which of the following code snippets sets the cookie which will expire when the browser is closed down?

Answers:

  1. var cookie_date = new Date ( );
    cookie_date.setTime ( cookie_date.getTime() — 1 );
    document.cookie = «username=John;password=John#1;expires=» + cookie_date.toGMTString();
  2. document.cookie = «username=John;password=John#1»;
  3. var cookie_date = new Date ( );
    cookie_date.setTime ( cookie_date.getTime() + 1000 );
    document.cookie = «username=John;password=John#1;expires=» + cookie_date.toGMTString();
  4. document.cookie = «username=John;password=John#1;expires=0»;

230. Imagine you have canvas which has image in its content. How to capture HTML Canvas as image?

Answers:

  1. var canvas = document.getElementById(«canvasID»);
    var url = canvas.toDataURL(«image/png»);
    document.write(‘<img src=»‘+url+’»/Z&lgt;’);
  2. var canvas = document.getElementById(«canvasID»);
    var context = canvas .getContext(«2d»);
    var imgData=ctx.getImageData(10,10,50,50);
    document.write(imgData);
  3. var canvas = document.getElementById(«canvasID»);
    var context = canvas .getContext(«2d»);
    var img=document.getElementById(«someImageId»);
    context.drawImage(img,0,0);
  4. It is not possible.

231. What kind of Typed Arrays representation of the pixels does Canvas ImageData return when you call ImageData.data?

Answers:

  1. Uint8ClampedArray
  2. Uint8Array
  3. Int8Array
  4. Uint32Array

232.Which of the following is not a valid variable name?

Answers:

  1. myvar
  2. my_var
  3. 5myvar
  4. myvar_5

233.Can Javascript functions be nested?

Answers:

  1. Yes
  2. No

234.Suppose you have several pages in different locations and need to implement messaging between them. How would you solve security issues?

Answers:

  1. Not to add any event listeners for message events. This is a completely foolproof way to avoid security problems.
  2. Always verify the sender’s identity using the origin and possibly source properties, always verify the syntax of the received message.
  3. use listener method in the following form
    function receiveMessage(event) {
    if (event.origin == senderURL) {
    return;
    }
    // do whatever you want
    }
    window.addEventListener(«message», receiveMessage, false);

235.What is the event that fires when the form element textarea loses the focus?

Answers:

  1. Onclick
  2. Ondbclick
  3. Onfocus
  4. Onblur

236.Which of the following can be used to handle the user clicking on a node?

Answers:

  1. node.addEventListener( “click”, myFunction, false)
  2. node.addEventListener( “onclick”, myFunction, false)
  3. node.onclick = myFunction
  4. node.attachEvent( “onclick”, myFunction)

237.Which of the following is not a mouse event?

Answers:

  1. onmousescroller
  2. onclick
  3. onmouseover
  4. onmousemove

238.What is the correct way to create a JavaScript array?

Answers:

  1. var cars = [“Saab”, “Volvo”, “BMW”];
  2. var cars = “Saab”, “Volvo”, “BMW”
  3. var cars = 1 = (“Saab”), 2 = (“Volvo”), 3 = (“BMW”)
  4. var cars = (1:”Saab”, 2:“Volvo”, 3:“BMW”);

239.What will following code print on browser console?

var foo = function foo() {
console.log(foo === foo);
};
foo();

Answers:

  1. true
  2. false
  3. nothing
  4. It will raise an exception.

240.What command skips the rest of a case statement?

Answers:

  1. return
  2. exit
  3. continue
  4. break

241. What method can’t be used with a window object?

Answers:

  1. open
  2. read
  3. write
  4. close

242. How can you detect the client’s browser name?

Answers:

  1. client.navName
  2. browser.appName
  3. navigator.appName
  4. None of these

243. Which of the following is/are the correct way to redirect to a URL in javascript?

Answers:

  1. document.href= ‘http://www.foobar.com’;
  2. window.location.assign (“http://www.foobar.com”)
  3. window.location = ‘http://www.foobar.com’;
  4. navigator.location = ‘http://www.foobar.com’;

244. Which of the following way is the best to check browser support for localStorage and sessionStorage?

Answers:

  1. if(typeof(Storage)!==”undefined”) {
    // Yes! localStorage and sessionStorage support:
    // Some code…..
    }
    else {
    // Sorry! No web storage support..
    }
  2. if(sessionStorage!==”undefined”) {
    // Yes! localStorage and sessionStorage support:
    // Some code…..
    }
    else {
    // Sorry! No web storage support..
    }
  3. if(typeof(localStorage)!==null && typeof(sessionStorage)!==null ) {
    // Yes! localStorage and sessionStorage support:
    // Some code…..
    }
    else {
    // Sorry! No web storage support..
    }
  4. if(localStorage)!==”undefined”) {
    // Yes! localStorage and sessionStorage support:
    // Some code…..
    }
    else {
    // Sorry! No web storage support..
    }

245. For the following html element, which is the correct method to change the font size to 25px using javascript?
<p id = “foo”>Lorem Ipsum&lt/p>

Answers:

  1. document.getElementById(“foo”).setFontSize = “25px”;
  2. document.getElementById(“foo”).style.FontSize = “25px”;
  3. document.getElementById(“foo”).fontSize = “25px”;
  4. document.getElementById(“foo”).style(“font-size = 25px”);

246. Which Window method is used to call a function or evaluate an expression at specified intervals?

Answers:

  1. setInterval()
  2. repeat()
  3. setTimeout()

247. What will be the output of following code?
function sum() {
var retval = 0;
for (var i = 0, len = arguments.length; i < len; ++i) {
retval += arguments[i];
}
return retval;
}
console.log(sum(1, 2, 3))

Answers:

  1. It will print 1 on browser console
  2. It will print 6 on browser console
  3. It will throw undefined message error

248. Which of following statements is incorrect regarding localStorage and sessionStorage?

Answers:

  1. localStorage — stores data with no expiration date
  2. sessionStorage — stores data for one session
  3. The data stored with session Storage is deleted when the user closes the browser window.
  4. The data stored with localStorage will not be deleted when the browser is closed, and will be available the next day, week, or year.
  5. None of above

249. Which of the following methods is used to get the current location of a user?

Answers:

  1. getUserPosition()
  2. getCurrentPosition()
  3. getPosition()
  4. None of above

250. Suppose you have a following Worker. How do you stop this Worker from the main page?
var w = new Worker(“”workers.js””);
Answers:

  1. w.terminate();
  2. w = null;
  3. w.close();
  4. w.postMessage(“stop”);

251.Which of the following statements is incorrect regarding HTML5 Web Worker?

Answers:

  1. A web worker is a JavaScript that runs in the background.
  2. It runs independently of other scripts, without affecting the performance of the page
  3. The data from the web worker is stored in event.source
  4. postMessage() method — which is used to posts a message back to the HTML page.

252.Which of the following statements is incorrect regarding HTML5 Geolocation?

Answers:

  1. The HTML5 Geolocation is used to get the geographical position of a user and much more accurate for devices with GPS.
  2. watchPosition() method of Geolocation object — returns the current position of the user and continues to return updated position as the user moves
  3. The getCurrentPosition() method returns an object if it is successful.
  4. The position is always available without the user permission

253. What is the output of the following code?
if (typeof(Storage)!==”undefined”) {
localStorage.age=5;
sessionStorage.age=5;
alert(localStorage.age + sessionStorage.age);
}
else {
alert(“Sorry, your browser does not support web storage…”);
}

Answers:

  1. 55
  2. 10
  3. Sorry, your browser does not support web storage…
  4. 5undefined

254. What is the output of the following code?
var foo = 123e5;
var bar = 10;
var foobar = foo + bar;
alert(foobar)

Answers:

  1. 12300010
  2. 1230000010
  3. 123e510
  4. 133

255. What will be the final output ?
var x=3;
x=x<<3;

Answers:

  1. 1
  2. 3
  3. 24
  4. 9

256. What will be the output of following code snippet?
var result = (function(a) {
return a*a;
}(5.5));
alert(result);

Answers:

  1. 5
  2. 25
  3. 10
  4. 30.25

257. What is the correct JavaScript syntax to change the content of next HTML element?
<p id=»sample»>This is a sample text.</p>

Answers:

  1. document.getElement(«p»).innerHTML = «Hello World!»;
  2. #sample.innerHTML = «Hello World!»;
  3. document.getElementById(«sample»).innerHTML = «Hello World!»;
  4. document.getElementByName(«p»).innerHTML = «Hello World!»;

258. What is the correct syntax for referring to an external script called «test.js»?

Answers:

  1. <script name=»test.js»>
  2. <script href=»test.js»>
  3. <script src=»test.js»>
  4. None of these

259. Which of the following code snippets deletes cookie correctly?

Answers:

  1. var mydate = new Date();
    mydate.setTime(mydate.getTime() — 1);
    document.cookie = «username=; expires=» + mydate.toGMTString();
  2. document.cookie = null;
  3. document.cookie = «username=John;password=John#1»;
  4. var mydate = new Date();
    mydate.setTime(mydate.getTime() + 1000000);
    document.cookie = «username=; expires=» + mydate .toGMTString();

260. What will the output of the below code?
function clickValue(){
alert(Math.round(-20.5));
}
clickValue();

Answers:

  1. -20
  2. -21
  3. 20
  4. 19.5

261. What is not true about anonymous functions?

Answers:

  1. anonymous functions are created at runtime.
  2. anonymous functions don’t have a name.
  3. anonymous functions can not return any value.
  4. All variables and functions defined within the anonymous function aren’t available to the code outside of it.

262.What will be the output of following code?
var x = 1;
{
var x = 2;
}
alert(x);

Answers:

  1. 1
  2. 2
  3. undefined
  4. code will raise an exception

263.new String(«This is a JavaScript string») instanceof String evaluates to?

Answers:

  1. False
  2. True
  3. Error
  4. String

264.Which of the following is the correct method to update the content of an HTML element ‘p’ with id = ‘foo’?

Answers:

  1. document.getElementById(«foo»).innerHTML = «some text»;
  2. document.getElementById(«foo»).HTML = «some text»;
  3. document.getElementById(«foo»).text = «some text»;
  4. document.getElementById(«foo»).text = «some text»;

265.What will be the output of following code snippet?
var foo = 10;
bar = 3;
(function() {
var foo = 2;
bar= 1;
}())
bar = bar + foo;
alert(bar);

Answers:

  1. 11
  2. 3
  3. 30
  4. 12

266.Which of the following is incorrect way of instantiating a date?

Answers:

  1. new Date(dateString)
  2. new Date()
  3. new Date(seconds)
  4. new Date(year, month, day, hours, minutes, seconds, milliseconds)

267.What will be the output of following code?
var x = [typeof x, typeof y][1];
console.log(typeof typeof x);

Answers:

  1. string
  2. object
  3. array
  4. It will raise an exception

268.What will this code output?
console.log(typeof a);
console.log(typeof b);
function a() {
}
var b = function () {
};

Answers:

  1. function, function
  2. function, undefined
  3. undefined, undefined
  4. undefined, function
  5. An error

269.Which of the following is a client side object?

Answers:

  1. Database
  2. FileUpLoad
  3. Client
  4. Cursor

270.How do you locate the first X in a string variable named txt?

Answers:

  1. txt.find(‘X’);
  2. txt.locate(‘X’);
  3. txt.indexOf(‘X’);
  4. txt.countTo(‘X’);

271.How to write an IF statement for executing some code if var «my_id» is NOT equal to 10?

Answers:

  1. if (my_id<>10)
  2. if my_id =! 10 then
  3. if my_id <>10
  4. if (my_id != 10)

272.Evaluate the following expression: ~-(2 + «2»)

Answers:

  1. undefined
  2. SyntaxError
  3. 21
  4. -22

273.What would be the output of below regular expression code:
/e/.exec(«The best things in life are free!»);

Answers:

  1. e
  2. 6
  3. 4
  4. true

274.What is the actual way to remove a property from an object?

Answers:

  1. by setting property to undefined
  2. by deleting the property using delete operator
  3. by setting property to null
  4. You can not delete an individual property from an object.

275.What is the use of «this» keyword in JavaScript?

Answers:

  1. It refers to current object
  2. It refers to previous object
  3. It is variable which contains value
  4. None of the above

276.Which of the following determines the type of a given object?

Answers:

  1. variable
  2. typeof
  3. string
  4. object

277. Which of the following is not a valid JavaScript Assignment Operator?

Answers:

  1. /=
  2. *=
  3. =
  4. %=
  5. ^

278. What is the correct JavaScript syntax to change the content of the HTML element with id «header»?

Answers:

  1. document.getElementById(«header»).innerHTML = «Updated Header!»;
  2. #header.innerHTML = «Updated Header!»;
  3. $header.innerHTML = «Updated Header!»;
  4. document.getElement(«p»).innerHTML = «Updated Header!»;

279. What will be the output of the following code?
var foo = 10 << 1;

Answers:

  1. 10
  2. 20
  3. 0
  4. 30

Brisingr (English, Paperback, Christopher Paolini)

Brisingr  (English, Paperback, Christopher Paolini)

brisingr-inheritance-eragon-inheritance-cycle-book-3-original-imadg3gfkkam4xhd

 Number 3 of the The Inheritance cycle Series

Following the colossal battle against the Empire’s warriors, Eragon and Saphira narrowly escaped with their lives. But more awaits the Rider and his dragon, as Eragon finds himself bound by promises he may not be able to keep, including his oath to cousin Roran to help rescue his beloved Katrina.

When unrest claims the rebels and danger strikes, Eragon must make choices that take him across the Empire and beyond, choices that may lead to unimagined sacrifice.

Conflict, action, adventure and one devastating death await readers as Eragon battles on behalf of the Varden while Galbatorix ruthlessly attempts to crush and twist him to his own purposes. Can he become a leader who can unite the rebel forces and defeat the King?

About the Author
Christopher Paolini was educated at home by his parents. His abiding love of fantasy and science fiction inspired him to begin writing his
debut novel, Eragon, when he graduated from high school at fifteen. He became a New York Times bestselling author at nineteen.

Christopher lives in Montana, USA, where the dramatic landscape fed his vision of Alagaesia.

COMPLETE DESKTOP COMPUTER Intel Core 2 Duo 3 GHZ, 4 GB, 500 GB, DVD RW , DELL 19 inch LED

Hey!!! Are you looking for an affordable desktop computer? Here is a complete desktop computer with amazing features at a very best price range.offers in amazon

Features:

  • INTEL CORE 2DUO 3 GHZ
  • RAM 4 GB HYNIX/KINGSTON
  • 500 GB HARDDRIVE,LG DVD RW
  • DELL 19 INCH LED
  • DELL MULTIMEDIA KEYBOARD,DELL OPTICAL MOUSE

 Technical Details

  • Brand: Tegh Computers
  • Colour: BLACK
  • Screen Size: 18.50 Inches
  • Item Weight: 10 Kg
  • Product Dimensions: 10 x 10 x 10 cm
  • Item model number: OPTIPLEX 755
  • Processor Speed: 3 GHz
  • RAM Size: 4 GB
  • Computer Memory Type: DDR2 SDRAM
  • Hard Drive Size: 500 GB
  • Hard Drive Interface: Serial ATA
  • Hardware Platform: Windows
  • Operating System: DOS
  • Included Components: Power cable, Mother board CD, Monitor, CPU

This complete desktop computer is available at the best price: 16,899.00 with FREE Delivery, Inclusive of all taxes.desktop computer

You can buy it online through different payment methods:

  • Cash on Delivery eligible
  • Online payment
  • You can also buy it with Credit card on EMI. It’s EMI starts at Rs. 1,509.37 per month.

Upwork Latest SEO TEST

Pass SEO test with rajat marketing mania

  1. Which of the following image file types can be indexed by Google?

Answers:

  1. TIFF
  2. RAW
  3. WEBP
  4. PNG
  1. Which of the following correctly describes what are considered to be “Doorway pages”?

Answers:

  1. Pages with a permanent redirect(301) to an external page with relevant content.
  2. Pages especially designed to link partner sites.
  3. Sets of poor-quality pages where each page is optimized for a specific keyword or phrase.
  4. None of these.
  1. What would be the impact of meta keywords on Google’s ranking algorithm?

Answers:

  1. Meta keywords are not used by Google.
  2. Multiple meta keywords may bring better results in SERP.
  3. Google encourages the use of a single meta keyword for each page.
  4. Multiple meta keywords get penalized by Google.
  1. Which of the following best describes the practice of “Google Bowling” from a negative SEO context?

Answers:

  1. Increasing the organic search ranking of a particular website or page by pointing hundreds or thousands of links at it, using very specific anchor text.
  2. Knocking a competitor out of the search results by pointing hundreds or thousands of low trust, low quality links at their website.
  3. Making a search engine believe that another website exists at a given URL.
  4. Using words which were traditionally associated with low quality content that caused search engines to want to demote the rankings of a page.
  1. Which of the following HTTP headers tells search engines when content has been changed since the site was last crawled?

Answers:

  1. If-Modified-Since
  2. Last-Modified
  3. ETag
  4. Server
  1. ]Which of the following is not a valid goal type from the perspective of Google Analytics?

Answers:

  1. Destination
  2. Duration
  3. Pages/Screens per visit
  4. Conversions
  1. Which of the following best describes a blog “TrackBack”?

Answers:

  1. An automated notification that a website mentioned another website; it is a built-in feature on most popular blogging software programs.
  2. A link from one website to another. It is also called an inbound link.
  3. A method used to break a page down into multiple points on the web graph by breaking its pages down into smaller blocks.
  4. It is a method for tracking visitors on a website.
  1. Which of the following practices are allowable under Google Webmaster Guidelines?

Answers:

  1. Using automated programs or services to create links to a site.
  2. Links with optimized anchor text in articles or press releases distributed on other sites.
  3. Forum commenting with optimized links in the post or signature.
  4. Advertising links that use the nofollow attribute.
  1. Please choose which of the following tool belongs to the Bing Search Engine?

Answers:

  1. Keyword Planner
  2. SEO Analyzer
  3. Object Browser
  4. Open Graph Debugger
  1. Which of the following rich snippet formats are supported by Google? Select all that apply.

Answers:

  1. Microdata
  2. Microformats
  3. Data Highlighter
  4. RDFa
  1. Which of the following is not a valid method for verifying site ownership on Google?

Answers:

  1. HTML file verification
  2. Meta tag verification
  3. Google Analytics code verification
  4. None of these.
  1. Which of the following statements is true about Sitemaps?

Answers:

  1. If a site is accessible on both the www and non-www versions of its domain, a separate Sitemap for each version must be submitted.
  2. A Sitemap file must contain no more than 50,000 URLs and must be no larger than 50MB when uncompressed.
  3. A Sitemap file should be specified under the following XML namespace: xmlns=”http://www.google.com/schemas/sitemap/0.9″.
  4. Google only accepts Sitemap files in XML format.
  1. Which of the following HTML attributes can be used to provide descriptive text for site assets that a search engine crawler doesn’t typically recognize?

Answers:

  1. DESC
  2. ALT
  3. TEXT
  4. ROBOT
  1. Which of the following practices may improve the Domain Authority rank of an automobile trading website?

A: Submitting the website to all directories that are available.
B: Getting backlinks from auto-niche blogs.
C: Getting backlinks from fashion-niche blogs.
D: Using Robots to post on forums.
E: Manually posting at least 50 comments/day.

Answers:

  1. A, D and E
  2. B
  3. B, D and E
  4. All of above.
  1. Which of the following is an example of “Cloaking”, which is considered a “black hat” SEO technique?

Answers:

  1. Sending a visitor to a different URL than the one they initially requested.
  2. Locating text behind an image.
  3. Serving a page of HTML text to search engines, while showing a page of images or Flash to users.
  4. Using CSS to position text off-screen.
  1. Which is the correct usage of the Keyword Planner Tool in order to get a Phrase Match search volume for “New York hotels”?

Answers:

  1. New York Hotels
  2. “New York Hotels”
  3. [New York Hotels]
  4. ?New York Hotels
  1. Which of the following statements is true about the effect of page load times to a page’s ranking in Google’s search results?

Answers:

  1. Page load times affect a page’s ranking, and is given the same importance as a page’s relevance to the search query.
  2. Page load times affect a page’s ranking, but is given lesser importance compared to a page’s relevance to the search query.
  3. Page load times do not affect a page’s ranking.
  4. Google gives up on crawling a page if its load time is greater than 5 seconds.
  1. Which of the following is true about Google’s treatment of keyword density in a given page?

Answers:

  1. Keyword density is no longer being considered by Google’s search algorithms.
  2. Targeted keywords should be used as frequently as possible in a page to maximize PageRank.
  3. Artificially increasing keyword density offers diminishing returns and may be penalized for “keyword stuffing” if taken too far.
  4. None of these.
  1. Which of the following examples are considered by Google as “auto-generated” content? Select all that apply.

Answers:

  1. Text translated by an automated tool without human review or curation before publishing
  2. Text generated from scraping Atom/RSS feeds or search results
  3. Text generated by the website’s content management system
  4. Text generated using automated synonymizing or obfuscation techniques
  1. Which of the following are recommended actions to take when a website is penalized by an “Unnatural links to your site” Manual Action from Google? Select all that apply.

Answers:

  1. Removing old content from the site.
  2. Preventing links that violate Google’s guidelines from passing PageRank.
  3. Using the Google Webmaster Tools to disavow any offending links that the site management isn’t responsible for.
  4. Requesting reconsideration of the site from Google.

Best Catch your Punjab State Lottery, Lohri Weekly Bumper Result On February HeRe

Best catch your Punjab State Lottery Result february, Result Feb here, the lottery associations make it possible to view the online result at here. Now all result will be disclosed on 20 feb.

We are very pleased by you while announcing that you can see this lucky draw openly disclosed  with video here… Every number and price information as soon as possible will be released on this site. Every single moment and part of it will make live here.

lohri bumper 2017 result

See your dreams, lucky numbers, lottery bumper draw.  For more information on delay visit here marketing mania

Punjab state lottery bumper result Announcements 2017

 Lohri bumper result Announcements or declare Feb

Get the result announcement or declare of punjab state lohri bumper 2017, Lucky draw of 19 january for 1st price 1 cr 75 lakhs, 2nd price 125000, 3rd price 500000. will coming soon or draw lohri bumper 2017 at feb.

lohri bumper 217 result

rajat marketing mania

We are pleased for your patience for more information on delay visit here marketing mania