Skip to main content

Posts

Interview question - Database schema design

This is a database schema design interview question I have attended recently. The interviewer asked me to design DB schema for the below data in an efficient and normalized way and write a query to retrieve " first name, last name, department and work phone numbers of  all employees who are managed by Frank Callea". The data is given below in the diagram. The schema that I have designed is given below. I have created 3 tables as below. Employee Table      EMPID FIRSTNAME                        LASTNAME                             DEPTID      MGRID ---------- -------------------------------- -------------------------------- ---------- ...

Factory Design Pattern using Reflection

Here I have given an implementation of Factory design pattern in Java using reflection.Please refer to the below link for a quick presentation about Java Refection APIs. www.cs.washington.edu/education/courses/.../reflection.ppt I am creating a DB factory which will create an instance of Database manager objects depends on the argument which is passed. Assume that we have an application running in 2 different environment where one environment uses Oracle as a database and another uses Solaris as a database.Upon initialization of the program we have to create a DB manager instance which should return Oracle or Solaris DB manager for the program. Here I have used reflection to avoid modification to the Factory class if we need to support a new data base tomorrow. I have factory class as below, DBFactory.java import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; public class DBFactory { private static HashMap m_Regi...

Simple Spring Dependency Injection example

In this article I will show you a simple example for Spring Dependency Injection which is also known as Inversion Of Control (IoC). I am using Spring Tool Suite for this example even though STS is not mandatory for Spring development. According to Wikipedia " Dependency injection is a software design pattern that allows removing hard-coded dependencies and making it possible to change them, whether at run-time or compile-time.". I think this is a precise and well defined definition for dependency Injection design pattern. Now it is our turn to understand how this design patter works and how it help to achieve the goal of design patterns i.e Well defined solutions to commonly existing problems or scenarios. Lets start with an example, We have a Vehicle interface and 2 child classes Car and Truck. Both Car and Truck has 2 methods printModel() and testEngine() inherited. I have created a File-> New -> Spring Project named SpringDI.I have create...

How to Pass SCJP or OCPJP in 2 weeks

Hi All, I would like to share my experiance with OCPJP 1.6 exam in this post. I had prepared for 2 weeks for this exam and passed this exam with 83%. Let me share the details about my preparation. I am an experianced programmer with experience in many Object Oriented Programming languages including Java and C++. First thing I used for my preparation is the book: SCJP Sun Certified Programmer for Java 6 Exam 310-065 By Kathy Sierra and Bert Bates.This book is an excellent one for preparation of OCPJP exam. You dont have to buy a copy of the book.Freely downloadable PDFs are available on the net and download and use it. Spend 1 full week on the above book , go thorough all the topics carefully. Prepare a Java environment and try as much programs as possible, which will make the concepts clear as well as it will boost confidence. Carefully attend the exercise questions at the end of each chapter and analyse your results. If required take the same exercise once again. Print th...

Symantec Interview questions for the role of a Senior Software Developer C++

Below I have mentioned a few interview questions for the role of a Senior Software Engineer at Symantec. They were looking for a Senior person with mainly Windows API programming experience. I had 7 rounds of interview including a 'lunch with Manager' and a Director's interview. I have mentioned the questions below. I hope this would help some Developers looking for Symantec Interview Questions. Let me know your comments... C++/ OOPS Questions Rate yourself in C++ The interviewer wrote a  class with 2 members , a char* and a HANDLE  and asked me to complete the class. He was mainly looking for proper assignment operator and copy constructors. What is polymorphism What is abstract class and when to use abstract class How is virtual function implemented What is vptr, is vptr created per class or per object What is strlen_s() call would do? When to throw or catch an exception? Explain a few Design Patterns? Where did you use singleton and Factory patterns? ...

Create SNMP Client in JAVA Using SNMP4j

Please follow the below mentioned steps to write a very simple SNMP4J application using Java and eclipse IDE. First you need to download a copy of SNMP4J.jar. You can get it from http://www.snmp4j.org/html/download.html Then you need to decide how you are going to test your application. Check whether you have access to any real network devices like Cisco routers or Juniper routers or whether you are aware of any SNMP agent running on any of your servers.There is nothing to worry if you cannot find one , you can start SNMP agent on your desktop machine as well. Here I am giving an example of how you can use your Windows machine to test your application by starting the SNMP service on the machine. I am using a Windows XP machine and below are the steps needed to start SNMP agent on the machine. 1. Go to Start->Control Panel -> Add or Remove Programs -> Add or Remove Windows Components      Select or Check "Management and Monitoring Tools". ...