Skip to main content

Posts

Showing posts from March 11, 2017

SQL Interview Questions

SQL Interview Questions  Posted by  admin SQL Interview Questions I have studied lot of websites and data related to the SQL interview questions for Tech Mahindra and different companies.I come up with questions and it answers which have been recentlly  asked in Tech mahindra Interview.I have added  IBM Interview Questions  also which are useful questions for IBM Company.I will keep updating the questions weekly or in 15 days so that the users of this site will get very useful information about what kind of SQL questions asked in different companies and users will get proper idea and companywise bifircation of the questions and answers.Following are some important SQL Interview Questions for Tech Mahindra : 1.What is subquery and what are different types of subqueries? Answer: Subquery is query within a query.There are 2 or more types of queries used to fetch output of the query.One is query used inside the query which is known as inner query and the output of query i

How to load data from CSV file in Java

How to load data from CSV file in Java - Example You can load data from a CSV file in Java program by using  BufferedReader  class from  java.io  package. You can  read the file line by line  and convert each line into an object representing that data. Actually there are couple of ways to read or parse CSV file in Java e.g. you can use a third party library like Apache commons CSV or you can use  Scanner  class, but in this example we will use traditional way of loading CSV file using BufferedReader. Here are the steps to load data from CSV file in Java without using any third party library : Open CSV file using FileReader object Create BufferedReader from FileReader Read file line by line using  readLine()  method Split each line on comma to get an array of attributes using  String.split()  method Create object of Book class from String array using new Book() Add those object into ArrayList using  add()  method Return the List of books to caller And here is our sam

MVC Architecture in Java

MVC Architecture in Java In this post we will understand and learn about MVC architecture in Java. We will also learn how to implement web application using using JSP and servlets technologies. MVC  is an open architecture with multiple tiers. As a java developer must have strong knowledge on MVC architecture,when ever you faced technical round interview question as experienced developer you should expect the question like tell me about your project architecture,so you should be in a position to answer this questions. MVC is a design pattern stands for Model,View and Controller. It can be used to design web applications in a standard manner that means  it will provide a pattern to design web applications. It can able to provide the roles and responsibilities of the components which we used in MVC pattern or architecture. Model:   Here model is a one of the component in MVC pattern. It maintains the business rules of your application and interact with the persistence storage to

Difference between ConcurrentHashMap, Hashtable and Synchronized Map in Java

Difference between ConcurrentHashMap, Hashtable and Synchronized Map in Java ConcurrentHashMap vs Hashtable vs Synchronized Map Though all three collection classes are thread-safe and can be used in multi-threaded, concurrent Java application, there is a significant difference between them, which arise from the fact that how they achieve their thread-safety. Hashtable is a legacy class from JDK 1.1 itself, which uses synchronized methods to achieve thread-safety. All methods of Hashtable are synchronized which makes them quite slow due to contention if a number of thread increases. Synchronized Map is also not very different than Hashtable and provides similar performance in concurrent Java programs. The only difference between Hashtable and Synchronized Map is that later is not a legacy and you can wrap any Map to create it's synchronized version by using  Collections.synchronizedMap()  method. On the other hand, ConcurrentHashMap is specially designed for concurrent us

How to generate random number in java

How to generate random number in java java.util.Random  class is use to generate  some random number  in java. Methods of Random class Method  Name Method Working protected int next(int bits) Use to generates the next pseudorandom number. double nextDouble() Returns the next pseudorandom float nextFloat() Returns the next pseudorandom int nextInt() Returns the next pseudorandom int nextInt(int n) Returns a pseudorandom long nextLong() Returns the next pseudorandom. Example package javaenotes; import java.util.Random; public class StudentInfo extends Thread { public static void main (String[] args) { Random random = new Random(); for (int i = 0; i < 5; i++) { int randomNumber = random.nextInt(); System.out.println("Random number: " + randomNumber); } } } Output Random number: 684985468 Random number: 824215667 Random number: 2099679075 Random number: -831622058 Random number: 979547511

BeanFactory and ApplicationContext

BeanFactory and ApplicationContext The org.springframework.beans   and   org.springframework.context   packages are the two most important and fundamental packages in Spring. These packages provides the basis for Spring's   Inversion of Control   ( Dependency Injection )  features. The   BeanFactory   provides configuration mechanism which is capable of managing beans (objects). The   ApplicationContext  is  build on top of the BeanFactory which adds other functionality such as message resource handling (for use in internationalization), event propagation, easier integration with Springs AOP features, declarative mechanisms.  The   BeanFactory   provides the configuration framework and basic functionality, while the   ApplicationContext   adds enhanced capabilities to it, some of them perhaps more J2EE and enterprise-centric. ApplicationContext is a superset of a BeanFactory, and BeanFactory capabilities and behavior apply to ApplicationContexts as well. At t