Posts

Runtime Polymorphism in java

Runtime Polymorphism: -------------------------------------------------- --------------------------------------------------- Polymorphism is the foundation of Object Oriented Programming. It means that one object can be have as another project. So how does on object can become other, its possible through following Inheritance Overriding/Implementing parent Class behavior Runtime Object binding One of the main advantage of it is switch implementations. Lets say you are coding an application which needs to talk to a database. And you happen to define a class which does this database operation for you and its expected to do certain operations such as Add, Delete, Modify. You know that database can be implemented in many ways, it could be talking to file system or a RDBM server such as MySQL etc. So you as programmer, would define an interface that you could use, such as...public interface DBOperation { public void addEmployee(Employee newEmployee); public void modifyEmployee(int id, Em...

A Brief Description about Web Services

Web Services: --------------------------- Why we need to go with Webservices? A: WebServices is one of the Distributed Technology like EJB and RMI. Problem with EJB and RMI: ------------------------- -->Language Dependent -->Robust -->Heavy Weight Benefits with WS: --------------------- WS is Interoperable which means Language Independent and Platform Independent and provide Enterprise services like other technologies EJB and RMI. WS flow: ------------ For Example what we need for communication b/w two persons? like we need --> Two persons --> Medium --> Language --> Rules (protocol). like that if two applications need to communicate we need --> Consumer : which consumes(using) the services --> Provider : Service provider --> protocaol : HTTP, FTP and SMTP. ( In internat world we prefer HTTP) --> Language : XML --> Medium : both applications should be connected (network). So the final conclusion is: "The Consumer will send XML to co...

Dispatcher Servlet Configuration in Spring and log4j Configuratin

Log4J : --------------- log4j.properties log4j.rootLogger=ERROR,console #Console Appender  log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=[%5p] [%t %d{hh:mm:ss}] (%F:%M:%L) %m%n #Custom assignments log4j.logger.controller=DEBUG,console log4j.logger.service=DEBUG,console log4j.logger.dao=DEBUG,console #Disable additivity log4j.additivity.controller=false log4j.additivity.service=false log4j.additivity.dao=false web.xml: -------------------- we can configure Dispatcher Servlet and context config location like as follows <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee ht...

Spring - Hibernate Integration Jars with Maven(POM)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">   <modelVersion>4.0.0</modelVersion>   <groupId>org.krams.tutorial</groupId>   <artifactId>spring-hibernate-mysql</artifactId>   <packaging>war</packaging>   <version>1.0.0-SNAPSHOT</version>   <name>spring-hibernate-mysql Maven Webapp</name>   <url>http://maven.apache.org</url>   <dependencies>   <dependency>   <groupId>junit</groupId>   <artifactId>junit</artifactId>   <version>4.8.1</version>   <type>jar</type>   <scope>compile</scope>   </dependency>   <dependency>     <groupId>org...

Lock ur Folder without any software

Open Notepad and copy the below code and save as (locker .bat). At first time start it will create folder with Locker automatically for u. Don't forget to change your password in the code its shown the place where to type your password. After creation of Locker folder again click on the locker.bat.it will ask. press Y then Locker folder will be disappeared. Again to get it click on locker.bat. And give ur password u will get the folder again. cls @ECHO OFF title Folder Locker if EXIST "Control Panel.{21EC2020- 3AEA-1069- A2DD-08002B30309 D}" goto UNLOCK if NOT EXIST Locker goto MDLOCKER :CONFIRM echo Are you sure u want to Lock the folder(Y/N) set/p "cho=>" if %cho%==Y goto LOCK if %cho%==y goto LOCK if %cho%==n goto END if %cho%==N goto END echo Invalid choice. goto CONFIRM :LOCK ren Locker "Control Panel.{21EC2020- 3AEA-1069- A2DD-08002B30309 D}" attrib +h +s "Control Panel.{21EC2020- 3AEA-1069- A2DD-08002B30309 D}" echo Folder locked g...

Spring and Hibernate Integration....

Integrating Hibernate with Spring I tried to learn how to integrate Hibernate with Spring and found very useful information in Spring in Action by Craig Walls. Before getting started let me tell you about the example I have used in this article. I am having a very basic table in database CREATE TABLE sample ( id int ( 10) unsigned NOT NULL AUTO_INCREMENT, name varchar ( 45) NOT NULL , city varchar ( 45) NOT NULL , PRIMARY KEY ( id) ) ; and here is Sample.hbm.xml < ? xml version = "1.0" ? > < ! DOCTYPE hibernate - mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > < hibernate - mapping > < class name = "hibernate.Sample" table = "sample" lazy = "false" > < id name = "id" column = "id" type = "java.lang.Long" > ...

Java Interview Questions

1)Why pointeres are eliminated from java.? Ans) 1.Pointers lead to confusion for a programmer. 2. Pointers may crash a program easily, for example , when we add two pointers, the program crashers immediately. 3. Pointers break security. Using pointers, harmful programs like Virus and other hacking programs can be developed. Because of the above reasons, pointers have been eliminated from java. 2) What is the difference between a function and a method.? Ans). A method is a function that is written in a class. We do not have functions in java; instead we have methods. This means whenever a function is written in java,it should be written inside the class only. But if we take C++, we can write the funtions inside as well as outside the class . So in C++, they are called member funcitons and not methods. 3) Which part of JVM will allocate the memory for a java program.? Ans). Class loader subsystem of JVM will allocate the necessary memory needed by the java progr...