Wednesday 6 September 2017

XML interview Questions?



What is XML?
XML is a file extension for an Extensible Markup Language (XML) file format used to create common information formats and share both the format and the data on the World Wide Web, intranets, and elsewhere using standard ASCII text.
XML is similar to HTML. Both XML and HTML contain markup symbols to describe the contents of a page or file. HTML, however, describes the content of a Web page (mainly text and graphic images) only in terms of how it is to be displayed and interacted with. For example, the letter "p" placed within markup tags starts a new paragraph.

What is the version information in XML?
“version” tag shows which version of XML is used.
Its used to uniquely identify the XML and enable the developer to identify which XML to be used in appropriate places.

What is ROOT element in XML?
In any markup language, the first element to appear is called the "root element", which defines what kind of document the file will be. In an HTML file, the <html> tag is the root element. An HTML file will always have the HTML element as the root element, while in an XML file, it can be anything.

In an XML file, there can only be one root element. The root element must encapsulate all other elements--meaning, these other elements must show up after the opening root tag and before the closing root tag. Here is an example of an XML document with the root element "phonebook".

XML Code:-

<phonebook>
            <number>
            </number>
            <name>
            </name>
</phonebook>

If XML does not have closing tag will it work?
No, every tag in XML which is opened should have a closing tag. For instance in the top if I remove </discount> tag that XML will not be understood by lot of application.

Is XML case sensitive?
Yes - XML is case sensitive.

What is the difference between XML and HTML?
  • XML was designed to carry data - with focus on what data is
  • HTML was designed to display data - with focus on how data looks
  • XML tags are not predefined like HTML tags are
  • XML store data - HTML present it

Is XML meant to replace HTML?
No. XML itself does not replace HTML. Instead, it provides an alternative which allows you to define your own set of markup elements. HTML is expected to remain in common use on the web, and the current versions of HTML (XHTML and HTML5) are in XML syntax.
XML is designed to make the writing of processing software much easier than with SGML, which is what the original HTML was based on.

Can you explain why your project needed XML?
XML was meant to exchange data between two entities as you can define your user friendly tags with ease. In real world scenarios XML is meant to exchange data. For
instance you have two applications who want to exchange information. But because they
work in two complete opposite technologies it’s difficult to do it technically. For instance
one application is made in JAVA and the other in .NET. But both languages understand
XML so one of the applications will spit XML file which will be consumed and parsed by
other applications

What is DTD (Document Type Definition)?
A DTD is a Document Type Definition.
A DTD defines the structure and the legal elements and attributes of an XML document.

Why Use a DTD?
With a DTD, independent groups of people can agree on a standard DTD for interchanging data.
An application can use a DTD to verify that XML data is valid.

An Internal DTD Declaration
If the DTD is declared inside the XML file, it must be wrapped inside the <!DOCTYPE> definition:

XML document with an internal DTD

<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)
>

<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>

An External DTD Declaration

<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
  
<to>Tove</to>
  
<from>Jani</from>
  
<heading>Reminder</heading>
  
<body>Don't forget me this weekend!</body>
</note>

And here is the file "note.dtd", which contains the DTD:

If the DTD is declared in an external file, the <!DOCTYPE> definition must contain a reference to the DTD file:
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>

What is well formed XML?

An XML document with correct syntax is called "Well Formed".
An XML document validated against a DTD is both "Well Formed" and "Valid".

What is a valid XML?

What is CDATA section in XML?

The CDATASection object represents a CDATA section in a document.
A CDATA section contains text that will NOT be parsed by a parser. Tags inside a CDATA section will NOT be treated as markup and entities will not be expanded. The primary purpose is for including material such as XML fragments, without needing to escape all the delimiters.
The only delimiter that is recognized in a CDATA section is "]]>" - which indicates the end of the CDATA section. CDATA sections cannot be nested.

Example:
The following markup code shows an example of CDATA. Here, each character written inside the CDATA section is ignored by the parser.
<script>
   <![CDATA[
      <message> Welcome to TutorialsPoint </message>
   ]] >
</script >


What is XSL?
What is element and attributes in XML?
Element :-
An XML element is everything from (including) the element's start tag to (including) the element's end tag.
Example:-
<price>29.99</price>

Attribute :
Attribute values must always be quoted. Either single or double quotes can be used.

For a person's gender, the <person> element can be written like this:
Example:
<person gender="female">


Which are the namespaces in .NET used for XML?

What are the standard ways of parsing XML document?
By using XMLDocument and XDocument

In What scenarios will you use a DOM parser and SAX parser?

How was XML handled during COM times?
What is the main difference between MSML and .NET Framework XML classes?
What are the core functionalities in XML .NET framework? Can you explain in detail those
functionalities?

What is XSLT?
With XSLT you can transform an XML document into HTML.

Define XPATH?
XPath is a major element in the XSLT standard.
XPath can be used to navigate through elements and attributes in an XML document.


What is the concept of XPOINTER?
What is an XMLReader Class?
What is XMLTextReader?
How do we access attributes using “XmlReader”?
Explain simple Walk through of XmlReader.
What does XmlValidatingReader class do?

Friday 18 August 2017

C#.Net Basic Questions?

What is an IL code?
Why IL code is not fully compiled?
Who compiles the IL code and how does it work?
How does JIT compilationwork?
What are different types of JIT?
What is Native Image Generator (Ngen.exe)?
So does it mean that NGEN.EXE will always improve performance?
What is a CLR?
What is the difference betweenmanaged and unmanaged code?
What is a garbage collector?
What are generations in Garbage collector (Gen 0, 1 and 2)?
Garbage collector cleans managed code, howdo we clean unmanaged code?
But when we create a destructor the performance falls down?
So how can we clean unmanaged objects and also maintain performance?
Can we force garbage collector to run?
What is the difference between finalize and dispose?
What is CTS?
What is a CLS (Common Language Specification)?
What is an Assembly?
What are the different types of Assembly?
What is Namespace?
What is Difference between NameSpace and Assembly?
What is ILDASM?
What is Manifest?
Where is the version information stored of an assembly?
Is versioning applicable to private assemblies?
What is the use of strong names?
What is Delay signing?
What is GAC?
How to add and remove an assembly from GAC?
If we have two versions of the same assembly in GAC how to we make a choice?
What is reflection?
What are stack and heap?
What are Value types and Reference types?
What is concept of Boxing and Unboxing?
How performance is affected due to boxing and unboxing?
How can we avoid boxing and unboxing?
How to prevent my .NET DLL to be decompiled?
What is the difference between Convert.toString and .toString () method?
How can we handle exceptions in .NET?
How can I know from which source the exception occurred?
What if we do not catch the exception?
What are system level exceptions and application level exceptions?
Can two catch blocks be executed?
What are different types of collections in .NET?
What is the difference between arraylist and list?
Are Arraylist faster or Arrays?
What are hashtable collections?
What are Queues and stack collection?
Can you explain generics in .NET?
Can you explain the concept of generic collection?
What is the difference between dictionary and hashtable?
What are the generic equivalent for array list,stack, queues and hashtable?
What is the use of IEnumerable, ICollection, Ilist and IDictionary?
What is code access security (CAS)?
So how does CAS actually work?
Is CAS supported in .NET 4.0?
What is sandboxing?
How can we create a windows service using .NET?
What is serialization and deserialization in .NET?
Can you mention some scenarios where we can use serialization?
When should we use binary serialization as compared to XML serialization?
Can you explain the concept of “Short Circuiting”?
What is the difference between “Typeof” and “GetType”?
Will the following c# code compile?

Saturday 14 January 2017

Virtual vs Overriding vs New keyword in c#?

Virtual and Overriding keyword are used for method overriding. Method overriding is concept of Polymorphism. New keyword is used for method hiding.
Now we check how to use this keyword in c# by example.

Example 1:-

namespace ConsoleProg
{
    class A
    {
        public void show()
        {
            Console.WriteLine("A");
        }
    }
    class B : A
    {
        public void show()
        {
            Console.WriteLine("B");
        }
    }
    class C : B
    {
        public void show()
        {
            Console.WriteLine("C");
        }
    }
    class Program
    {
        static void Main()
        {
            A a = new A();
            a.show();   // print-- A
            B b = new B();
            b.show();  // print-- B
            C c = new C();
            c.show(); // print-- C

            A a1 = new B();
            a1.show(); // print-- A
        }
    }
}
Note:- But it show some warning message.

1.) 'ConsoleProg.B.show()' hides inherited member 'ConsoleProg.A.show()'. Use the new keyword if hiding was intended.
 2.) ‘ConsoleProg.C.show()' hides inherited member 'ConsoleProg.B.show()'. Use the new keyword if hiding was intended.  
Solution of the above warning is use either new keyword or overriding keyword in derived class in method.

Virtual And Overriding keyword (Method overriding):-

If you want to be method overriding in the derived class, then the base class method must have the virtual keyword otherwise it will throw an error.

Example 2:-

namespace ConsoleProg
{
    class A
    {
        public virtual void show()
        {
            Console.WriteLine("A");
        }
    }
    class B : A
    {
        public override void show()
        {
            Console.WriteLine("B");
        }
    }
    class C : B
    {
        public override void show()
        {
            Console.WriteLine("C");
        }
    }
    class Program
    {
        static void Main()
        {
            A a = new A();
            a.show();   // print-- A
            B b = new B();
            b.show();  // print-- B
            C c = new C();
            c.show(); // print-- C

            A a1 = new B();
            a1.show(); // print-- B
        }
    }
}

New Keyword (Method hiding):

New keyword is used for method hiding the base class method from derived class.

Example 3:-

namespace ConsoleProg
{
    class A
    {
        public void show()
        {
            Console.WriteLine("A");
        }
    }
    class B : A
    {
        public new void show()
        {
            Console.WriteLine("B");
        }
    }
    class Program
    {
        static void Main()
        {
            A a = new A();
            a.show();   // print-- A
            B b = new B();
            b.show();  // print-- B

            A a1 = new B();
            a1.show(); // print-- B
        }
    }
}

Method Overriding and Hiding:-

Example 4:-

 namespace ConsoleProg
{
    class A
    {
        public  void show()
        {
            Console.WriteLine("A");
        }
    }
    class B : A
    {
        public new virtual void show()
        {
            Console.WriteLine("B");
        }
    }
    class C : B
    {
        public override void show()
        {
            Console.WriteLine("C");
        }
    }
    class Program
    {
        static void Main()
        {
            A a = new A();
            a.show();   // print-- A
            B b = new B();
            b.show();  // print-- B
            C c = new C();
            c.show(); // print-- C

            A a1 = new B();
            a1.show(); // print-- A

            B b2 = new C();
            b2.show();  // print-- C

            A a2 = new C();
            a2.show();// print-- A
        }
    }
}

Example 5:

namespace ConsoleProg
{
    class A
    {
        public virtual void show()
        {
            Console.WriteLine("A");
        }
    }
    class B : A
    {
        public override void show()
        {
            Console.WriteLine("B");
        }
    }
    class C : B
    {
        public override void show()
        {
            Console.WriteLine("C");
        }
    }
    class Program
    {
        static void Main()
        {
            A a = new A();
            a.show();   // print-- A
            B b = new B();
            b.show();  // print-- B
            C c = new C();
            c.show(); // print-- C

            A a1 = new B();
            a1.show(); // print-- A

            B b2 = new C();
            b2.show();// print-- C

            A a2 = new C();
            a2.show();// print-- C
        }
    }
}
Example 6:
namespace ConsoleProg
{
    class A
    {
        public virtual void show()
        {
            Console.WriteLine("A");
        }
    }
    class B : A
    {
        public override void show()
        {
            Console.WriteLine("B");
        }
    }
    class C : B
    {
        public new void show()
        {
            Console.WriteLine("C");
        }
    }
    class Program
    {
        static void Main()
        {
            A a = new A();
            a.show();   // print-- A
            B b = new B();
            b.show();  // print-- B
            C c = new C();
            c.show(); // print-- C

            A a1 = new B();
            a1.show(); // print-- A

            B b2 = new C();
            b2.show(); // print-- B

            A a2 = new C();
            a2.show(); // print-- B
        }
    }
}

Important Point:

Override:-
      1.) Use this keyword polymorphism implementation along with virtual.  
      2.) With same name and parameter as in base class.
      3.) It is call called as run time polymorphism.
      4.) Also called as late binding.

New :-
     1.) It is used in polymorphism concept.
     2.) With same name and different parameters.  
     3.) Compile time bindig.
     4.) Also called early binding.