Interview Questions and Answers

An XML document is called well-formed if it satisfies certain rules, specified by the W3C.

These rules are:


1. A valid XML document is defined in the XML specification as a well-formed XML document which also conforms to the rules of a Document Type Definition (DTD) or a XML schema. According to JavaCommerce.com XML tutorial, "Well formed XML documents simply markup pages with descriptive tags. You don't need to describe or explain what these tags mean. In other words a well formed XML document does not need a DTD, but it must conform to the XML syntax rules. If all tags in a document are correctly formed and follow XML guidelines, then a document is considered as well formed."

2. There are languages developed specifically to express XML schemas. The document type definition (DTD) language, which is native to the XML specification, is a schema language that is of relatively limited capability, but that also has other uses in XML aside from the expression of schemas. Two more expressive XML schema languages in widespread use are W3C XML Schema (with a capital S) and RELAX NG.

wiki on XML schema     wiki on XSD or W3C XML Schema


List of XML parsing error:

  Description
1 The parser detected an invalid character when scanning white space outside element content.
2 The parser detected an invalid start of a processing instruction, element, comment, or document type declaration outside element content.
3 The parser detected a duplicate attribute name.
4 The parser detected the markup character ‘<‘ in an attribute value.
5 The start and end tag names of an element were different.
6 The parser detected an invalid character in element content.
7 The parser detected an invalid start of an element, comment, processing instruction, or CDATA(character Data) section in element content.
8 The parser detected in element content the CDATA closing character sequence ‘]]>’ without the matching opening character sequence ‘<![CDATA[‘.
9 The parser detected an invalid character in a comment.
10 The parser detected in a comment the character sequence ‘–‘ (two hyphens) not followed by ‘>’.
11 The parser detected an invalid character in a processing instruction data segment.
12 A processing instruction target name was ‘xml’ in  any of the cases- lower, upper or toggle.
13 The parser detected an invalid digit in a hexadecimal character reference (of the form &#xdddd;, for example &#x0eb1).
14 The parser detected an invalid digit in a decimal character reference (of the form &#dddd;).
15 A character reference did not refer to an authorized XML character.
16 The parser detected an invalid character in an entity reference name.
17 The parser detected an invalid character in an attribute value.
18 The parser detected a possible invalid start of a document type declaration.
19 The parser detected a second document type declaration.
20 An element name was not specified correctly. The beginning character was not a letter, ‘_’, or ‘:’, or the parser detected an invalid character either in or following the element name.
21 An attribute was not specified correctly. The beginning character of the attribute name was not a letter, ‘_’, or ‘:’, or a character other than ‘=’ was detected following the attribute name, or one of the delimiters of the value was not correct, or an invalid character was detected in or following the name.
22 An empty element tag was not terminated by a  markup language character ‘>’ following the ‘/’.
23 The element end tag wasn’t specified correctly. The beginning character was not a letter, ‘_’, or ‘:’, or the tag wasn’t terminated by ‘>’.
24 The parser detected an invalid start of a comment or CDATA section in element content.
25 A processing instruction target name wasn’t specified correctly. The starting character of the processing instruction target name wasn’t a letter, ‘_’, or ‘:’, or the parser detected an invalid character in or following the processing instruction target name.
26 A processing instruction wasn’t terminated by the closing character sequence ‘?>’.
27 The parser detected an invalid character following ‘&’ in a character reference or entity reference.
28 The version information wasn’t present in the XML declaration.
29 The ‘version’ in the XML declaration wasn‘t specified correctly. ‘version’ was not followed by ‘=’, or the value was not present or improperly delimited, or the value specified a bad character, or the start and end delimiters didn’t match, or the parser detected an invalid character following the version information value closing delimiter in the XML declaration.
30 The parser detected an invalid attribute instead of the optional encoding declaration in the XML declaration.
31 The encoding declaration value in the XML declaration was missing or incorrect. The value did not start with lowercase or uppercase A through Z, or ‘encoding’ wasn’t followed by ‘=’, or the value was missing or improperly delimited or it specified a bad character, or the start and end delimiters didn’t match, or the parser detected an invalid character following the closing delimiter.
32 The parser detected an invalid attribute instead of the optional standalone declaration in the XML declaration.
33 The ‘standalone’ attribute in the XML declaration wasn’t specified correctly. ‘standalone’ wasn’t followed by a ‘=’, or the value was either missing or improperly delimited, or the value was neither ‘yes’ nor ‘no’, or the value specified a bad character, or the start and end delimiters did n’t match, or the parser detected an invalid character following the closing delimiter.
34 The XML declaration wasn’t terminated by the proper character sequence ‘?>’, or contained an invalid attribute.
35 The parser detected the start of a document type declaration after the end of the root element.
36 The parser detected the start of an element after the end of the root element.

 

Top 100 Coding Problems from Programming Job interviews
  • How is a bubble sort algorithm implemented? (solution)
  • How is a merge sort algorithm implemented? (solution)
  • How do you count the occurrence of a given character in a string? (solution)
  • How do you print the first non-repeated character from a string? (solution)
  • How do you convert a given String into int like the atoi()? (solution)
  • How do you implement a bucket sort algorithm? (solution)
  • How do you implement a counting sort algorithm? (solution)
  • How do you remove duplicates from an array in place? (solution)
  • How do you reverse an array in place in Java? (solution)
  • How are duplicates removed from an array without using any library? (solution)
  • How is a radix sort algorithm implemented? (solution)
  • How do you swap two numbers without using the third variable? (solution)
  • How do you check if two rectangles overlap with each other? (solution)
  • How do you design a vending machine? (solution)
  • How do you find the missing number in a given integer array of 1 to 100? (solution)
  • How do you find the duplicate number on a given integer array? (solution)
  • How do you find duplicate numbers in an array if it contains multiple duplicates? (solution)
  • Difference between a stable and unstable sorting algorithm? (answer)
  • How is an iterative quicksort algorithm implemented? (solution)
  • How do you find the largest and smallest number in an unsorted integer array? (solution)
  • How do you reverse a linked list in place? (solution)
  • How to add an element at the middle of the linked list? (solution)
  • How do you sort a linked list in Java? (solution)
  • How do you find all pairs of an integer array whose sum is equal to a given number? (solution)
  • How do you implement an insertion sort algorithm? (solution)
  • How are duplicates removed from a given array in Java? (solution)
  • how to remove the duplicate character from String? (solution)
  • How to find the maximum occurring character in given String? (solution)
  • How is an integer array sorted in place using the quicksort algorithm? (solution)
  • How do you reverse a given string in place? (solution)
  • How do you print duplicate characters from a string? (solution)
  • How do you check if two strings are anagrams of each other? (solution)
  • How do you find all the permutations of a string? (solution)
  • How can a given string be reversed using recursion? (solution)
  • How do you check if a given string is a palindrome? (solution)
  • How do you find the length of the longest substring without repeating characters? (solution)
  • Given string str, How do you find the longest palindromic substring in str? (solution)
  • How do you check if a string contains only digits? (solution)
  • How to remove Nth Node from the end of a linked list? (solution)
  • How to merge two sorted linked list? (solution)
  • How to convert a sorted list to a binary search tree? (solution)
  • How do you find duplicate characters in a given string? (solution)
  • How do you count a number of vowels and consonants in a given string? (solution)
  • How do you reverse words in a given sentence without using any library method? (solution)
  • How do you check if two strings are a rotation of each other? (solution)
  • How to convert a byte array to String? (solution)
  • How do you remove a given character from String? (solution)
  • How do you find the middle element of a singly linked list in one pass? (solution)
  • How do you check if a given linked list contains a cycle? How do you find the starting node of the cycle? (solution)
  • How do you reverse a linked list? (solution)
  • How do you reverse a singly linked list without recursion? (solution)
  • How are duplicate nodes removed in an unsorted linked list? (solution)
  • How do you find the length of a singly linked list? (solution)
  • How do you find the third node from the end in a singly linked list? (solution)
  • How do you find the sum of two linked lists using Stack? (solution)
  • What is the difference between array and linked list? (answer)
  • How to remove duplicates from a sorted linked list? (solution)
  • How to find the node at which the intersection of two singly linked lists begins. (solution)
  • Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. (solution)
  • How to check if a given linked list is a palindrome? (solution)
  • How to remove all elements from a linked list of integers which matches with given value? (solution)
  • How is a binary search tree implemented? (solution)
  • How do you perform preorder traversal in a given binary tree? (solution)
  • How do you traverse a given binary tree in preorder without recursion? (solution)
  • How do you perform an inorder traversal in a given binary tree? (solution)
  • How do you print all nodes of a given binary tree using inorder traversal without recursion? (solution)
  • How do you implement a postorder traversal algorithm? (solution)
  • How do you traverse a binary tree in postorder traversal without recursion? (solution)
  • How are all leaves of a binary search tree printed? (solution)
  • How do you count a number of leaf nodes in a given binary tree? (solution)
  • How do you perform a binary search in a given array? (solution)
  • How to Swap two numbers without using the third variable? (solution)
  • How to check if two rectangles overlap with each other? (solution)
  • How to design a Vending Machine? (solution)
  • How to implement an LRU Cache in your favorite programming language? (solution)
  • How to check if a given number is a Palindrome? (solution)
  • How to check if a given number is an Armstrong number? (solution)
  • How to find all prime factors of a given number? (solution)
  • How to check if a given number is positive or negative in Java? (solution)
  • How to find the largest prime factor of a given integral number? (solution)
  • How to print all prime numbers up to a given number? (solution)
  • How to print Floyd’s triangle? (solution)
  • How to print Pascal’s triangle? (solution)
  • How to calculate the square root of a given number? (solution)
  • How to check if the given number is a prime number? (solution)
  • How to add two numbers without using the plus operator in Java? (solution)
  • How to check if a given number is even/odd without using Arithmetic operator? (solution)
  • How to print a given Pyramid structure? (solution)
  • How to find the highest repeating world from a given file in Java? (solution)
  • How to reverse given Integer in Java? (solution)
  • How to convert a decimal number to binary in Java? (solution)
  • How to check if a given year is a leap year in Java? (solution)
  • Can you implement a Binary search Algorithm without recursion? (solution)
  • Difference between a stable and unstable sorting algorithm? (answer)
  • What is Depth First Search Algorithm for a binary tree? (solution)
  • How is an iterative quicksort algorithm implemented? (solution)
  • How do you implement an insertion sort algorithm? (solution)
  • How is a merge sort algorithm implemented? (solution)
  • What is the difference between Comparison and Non-Comparison Sorting Algorithms? (answer)
  • How do implement Sieve of Eratosthenes Algorithms for Prime Number? (solution)

  • HTML Interview Questions

    What are the new <input> types for form validation in HTML5?

    The new input types for form validation are email, URL, number, tel, and date.

    Example:

    1. <input type="email">  

     

    JavaScript Interview Questions

    11) If we want to return the character from a specific index which method is used?

    The JavaScript string charAt() method 

    12) What is the difference between JavaScript and JScript?

    23) What is the difference between == and ===?

    The == operator checks equality only whereas === checks equality, and data type, i.e., a value must be of the same type.

    29) What is the output of 10+20+"30" in JavaScript?

    3030

    30) What is the output of "10"+20+30 in JavaScript?

    102030 because after a string all the + will be treated as string concatenation operator (not binary +).

    49) What is the requirement of debugging in JavaScript?

    JavaScript didn't show any error message in a browser. However, these mistakes can affect the output. The best practice to find out the error is to debug the code. The code can be debugged easily by using web browsers like Google Chrome, Mozilla Firebox.

    To perform debugging, we can use any of the following approaches:

    51) What is the role of a strict mode in JavaScript?

    Strict Mode was a new feature in ECMAScript 5 that allows you to place a program, or a function, in a “strict” operating context. This strict context prevents certain actions from being taken and throws more exceptions. The statement “use strict”; instructs the browser to use the Strict mode, which is a reduced and safer feature set of JavaScript.

    Benifits of using use strict: Strict mode makes several changes to normal JavaScript semantics.

    How to use strict mode: Strict mode can be used in two ways, remember strict mode doesn’t work with block statements enclosed in {} braces.


    https://www.oracletutorial.com/plsql-tutorial/oracle-instead-of-triggers/

    Summary: in this tutorial, you will learn how to use an Oracle INSTEAD OF trigger to insert data into tables via a non-updatable view.

    What is an instead of trigger in Oracle

    An INSTEAD OF trigger is a trigger that allows you to update data in tables via their view which cannot be modified directly through DML statements. When you issue a DML statement such as INSERTUPDATE, or DELETE to a non-updatable view, Oracle will issue an error. Check it out for more information on the updatable view.

    If the view has an INSTEAD OF trigger, it will automatically skip the DML statement and execute other DML statements instead. Note that an INSTEAD OF trigger is fired for each row of the view that gets modified. In Oracle, you can create an INSTEAD OF trigger for a view only. You cannot create an INSTEAD OF trigger for a table.


    https://www.oracletutorial.com/oracle-view/oracle-updatable-view/

    Summary: in this tutorial, you will learn about Oracle updatable view and how to insert or update data in the base tables through a view.