javarevisited

javarevisited


How to find second highest or maximum salary of Employee in SQL - Interview question

Posted: 22 Dec 2012 07:40 PM PST

How to find second highest or second maximum salary of an Employee is one of the most frequently asked SQL interview question similar to finding duplicate records in table and when to use truncate vs delete. There are many ways to find second highest salary based upon which database you are using as different database provides different feature which can be used to find second maximum or Nth maximum salary of employee. Well this question can also be generalized with other scenario like finding second maximum age etc. In this SQL tutorial we will see different example of SELECT SQL query to find second highest salary independent of databases or you may call in ANSI SQL and other SQL queries which uses database specific feature to find second maximum salary.
Read more »

XPath Tutorial - How to select elements in XPATH based on attribute and element value example

Posted: 22 Dec 2012 05:10 AM PST

In this XPATH tutorial we will see example of selecting elements based upon its value or attribute value. We will see how to select between two elements based upon value of its child elements or based upon value of its attribute. XPATH is an important concept to understand if you are working with XML files. Most of Back-office platform relies on XML files for transporting data from one system to other and if you are working on any back-office or middle office system in Java or .NET, its important to know about XPATH and be able to use XPATH to select data from XML. Some time back I have shared my XPATH notes for Java programmer and this example shows true power of XPATH as how convenient its to made selective decision. For those who are completely new in XML and XPATH, XPATH is great xml tool which allows you to query XML document and select or retrieve selective data much like SQL but if you are new to XPATH or haven't had much experience with XML tool and technology than you will struggle to find correct syntax of XPATH for your different need.
Read more »

Constructor Chaining in Java - Calling one constructor from another using this and super

Posted: 22 Dec 2012 01:27 AM PST

Constructor Chaining in Java
In Java you can call one constructor from another and it's known as constructor chaining in Java. Don't confuse between constructor overloading and constructor chaining, former is just a way to declare more than one constructor in Java. this and super keyword is used to call one constructor from other in Java. this() can be used to call other constructor of same class while super() can be used to call constructor from super class in Java. Just keep in mind that this() in realty calls no argument constructor of same class, while this(2) calls another constructor of same class which accepts one integer parameter. Similarly super() can be used to call no argument constructor of super class and super with parameter can be used to call other overloaded constructor of parent class. Calling one constructor from other is called constructor chaining in Java, which we seen while discussing constructor overloading in Java. Constructor chaining is also used to implement telescoping pattern where an object can be created with combination of multiple property. In our last tutorial we have seen some important properties of Java constructor as well as answered question What is Constructor in Java and in this Java tutorial we will see example of how to call one constructor from other for same class and super class.
Read more »


Post a Comment