Krish

Archive for July, 2009|Monthly archive page

Java-Basic Concepts

In Java-Basic Concepts on July 7, 2009 at 4:52 PM

CHAPTER-I

What is Java?

Java is an Object Oriented Programming Language.

What is meant by Object Orientation?

Object Orientation means, everything is object. confusing? The programming simulates into different objects to simplify the programming and avoid tight coupling.

Each object have some characterstics and some features.

Ex: take a person is a real-world object have some characterstics like name,designation etc…and some features like walk,read,eat etc…

got my point….like that..DOG,CAT etc are different objects.

Like this in JAVA we will deal everything with Objects.

How can we differentiate the Object Orientation Programming and Procedural Programming?

In procedural program ,programming logic follows certain procedures and the instructions are executed one after another.

In OOPs program,unit of program is object,which is nothing but combination of data and code.

In procedural program,data is exposed to the whole program where as in OOP’s program ,it is accesible within the object and which in turn assures the security of the  code.

Is there any other features in OOPs?

Yes, we have some features called Object Oriented Concepts.

  • Data Encapsulation
  • Abstraction
  • Inheritance
  • Polymorphism

What is Data Encapsulation?

Encapsulation means, in simple terms, Putting all the data at one place.

Ex 1: The Medicine capsule have the main medicine powder capsuled in a sugar coated capsule box. Like that put all the elements under one palce called ‘Data Encapsulation’. we can learn more about this in next chapters.

Ex 2: Put all your books in one box.

What is Abstraction?

Abstraction is a kind of data hiding. “Showing essential data and hiding non-essential data”.

Ex: If you go to a jewellary shop and ask for pearls, the person will show you only pearls, put all the gold items in the show cases or in their respective places.

What is Inheritance?

Inheritance means, “Acquiring properties from super class”.

Ex: Acquiring land properties of your father to you….

What is Polymorphism?

the word itself says the definition. Poly-menas Many Morphism- forms.

Means an object work in many forms.

Ex: you are only once. But if you are a student, you are student in your college. you are a gym trainer in gym after your college.

 you are brother to your sister, friend to your friend, lover to your GF . 🙂

CHAPTER-II

 Why Java treated as a Object Oriented?

As we discussed previously, in OOP, everything acts as an object.Also JAVA adopt to the OOPs concepts like data encapsulation,abstraction,Inheritance,Polymorphism.

So it’s called “Object Oriented Programming Language”.

How Java Diffent from Other Object Oriented Program Languages?

 Other languages like C++, would have the OOPs concepts. but they are plotform dependent.

Java is Plotform Independent language. Not understanding???

If you write a program in one plotform (windows), you can run the program on different plotform (Linux,Unix). It will run in different plotform.

only thing we need to do is set up the path, classpath settings.

How Java is Plotform Independent?

To answer this question, we need to know little bit about java program compilation.

Java have 2 step process for complie and run the application. that is 1) Compilation 2) Interpretation

Compilation: once you write the program, and compiles the program, it will creat a .class file (Byte Code).

Interpretation: After getting the .class file, the interpreter interprets the code (Checking line-by-line) and creates the executable file.

Once we get the byte code (.class file), we can take that code and run on any plotform, it will run the java program.

That’s why java compile once and run anywhere….so it is plotform independent.

How can we compile and Run a Java program?

To Compile a java program, we require JDK (Java Development ToolKit). Which contains both Java Compiler and JRE (Java run time Environment).

We need to install the JDK to write a java program and compile the program. we need to set up the path. (we will check in next chapter).

Is JDK also Plotform Independent?

 No, JDK is plotform Dependent. Because JRE is plotform dependent. the JRE is different for different plotforms.

Is it necessary to have JDK in every machine to run the Java Application/Program?

 No, It’s not necessary to have install JDK in every machine to run the application. if we have the Byte code of an application and want to run the program, we need to set up the path  and run the program.

JRE will come with Every Operating System. we need set the path to JRE to run the java program.

Chapter-III

 

In Previous chapter, we have discussed about path and classpath…but what is this path and classpath and why we need to set these variables. what is thier role?? we have to learn that…

What is path?

An environment variable that lists the directories the command processor searches for *.exe.

If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as:

C:\Program Files\Java\jdk1.6.0\bin\javac MyClass.java

What is classpath?

The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes. (Classes that are part of the JRE, JDK platform, and extensions should be defined through other means, such as the bootstrap class path or the extensions directory.)

 The default value of the class path is “.”, meaning that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp command line switch overrides this value.

To set classpath, the process is: MyComputer –>(right click): properties –>Advanced –> Environmental variables . You can create classpath variable or modify if already.

same thing for path setting as well.

You will get more info regarding path and classpath in below link.

http://www.dil.univ-mrs.fr/~garreta/docJava/tutorial/essential/environment/paths.html

 

Chapter-IV

In This Chapter we will learn about the basic java programming. And also compilation and running of a basic java program.

The Basic Structure of a java program is look like this.

class  Helloworld
{
    public static void main(String[] args)
   {
       System.out.println(”Hai Welcome to learning Java”);
  }
}

We will learn about step-by-step:

First check the line #1: class Helloworld.

     In java the program start with a block (which is having ‘{’ and ‘}’) called class. Helloworld is the name of the class. you can give any name in this place. This is the name of the class.

line#2:

public static void main(String[] args)

we will learn about each and every word in next few chapters. This is the main method. this is as like main() in ‘C’ language.

Any java program contains only one main method. The Program Execution follows from the main. So main is the starting point of a java program execution.

line#3:

System ==> This is Java built in class used for get some system properties like input stream, outputstream, path etc…

out==> this is the output stream.

println() ==> this method will print the message in console.This will print the message with in it.

Ex: Here it will print as “Hai Welcome to learning Java

This is same as printf in ‘C’.

So how to compile this program and run this program.

Do follow the steps:

1. Set the path first (see previous chapter-III)

2. Create a folder name “JavaPrograms”  in C:\  in your Computer (you can create any wher. may be in D:\ or E:\ and the folder name will be any thing.Just for reference i put Java Programs).

3. Save your program in thsi folder with Helloworld.java

4. Go to Start–>run–>type ‘cmd’ (it will open the command prompt)

5. Type cd.. and then type as cd javaprograms

then it will look like C:\javaprograms> in command prompt.

6. javac Helloworld.java (This is called java compilation)

    it will create a Helloworld.class file i nyour C:\Javaprograms folder.

7. After that

    java Helloworld (run the java program)

8. it will print “Hai Welcome to learning Java“.

Chapter-V

 

In Last chapter we learn about the simple java program. In this chapter we will learn about how the compilation and interpretation happened internally.

Once you write the program and try to compile it using Javac command… the JVM will complile the program.

What is JVM?

JVM: Java Virtual Machine, which contains the JDK as well as JRE. it provides the java environment.

JDK: Java Development toolkit. have compiler.

JRE: Java Runtime environment. this is for run the application or program

JVM = JDK+JRE;

To develop and run a java program we require JVM. but for running a java program JVM need not be required (As JRE come with OS). We already discuss about this in previous chapters.

Once the compilation successfully done, a .class file will generated… we can run this .class file using interpreter, after interpretation, the .exe file will be generated.

Why JVM is Plotform Dependent?

Java “the language” is platform-independent. To make it so, there is a platform-specific JRE that knows how to run the platform-independent Java code on a specific platform. So JVM is plotform dependent.

****************************************************************************************************************************************************************************

Summary

  •  Java is OOPs programming language and plotform independent language.
  • Java compilation and running is a two step process called compilation+interpratation
  • Java is secure becasue of byte code as well as interpretation.
  • To develop a java application we require JVM
  • JVM = JDK+JRE.
  • JVM is plotform dependent.
  • The file should be saved with same name as classname.

Useful Links for Java/J2EE

In Useful Links on July 7, 2009 at 3:51 PM

Java J2ee IQA: http://javastream-pshankar.blogspot.com/

 

inheritance : http://java.sun.com/docs/books/tutorial/java/concepts/inheritance.html

SOA(Service Oriented Architecture) http://www.javaworld.com/javaworld/jw-06-2005/jw-0613-soa.html

Serialization : http://www.javabeginner.com/uncategorized/java-serialization

Struts : http://www.developer.com/java/ent/article.php/1495931

Collections : http://www.javabeginner.com/java-collections/java-collections-framework

 

Do’s n Don’ts of Java Interview  : http://www.developer.com/java/data/article.php/3819171

 

New Features of Java 5.0 : http://www.codeproject.com/KB/java/Java5FeaturesI.aspx

New Features of Java 6.0 : http://www.javabeat.net/articles/14-java-60-features-part-2-pluggable-annotation-proce-1.html

New features of Java 7.0 : http://www.javabeat.net/articles/120-new-features-in-java-70-part-1-1.html

New Features of Java EE 6.0 : http://www.javabeat.net/articles/99-new-features-in-java-ee-60-1.html

New features of Struts 2.0 : http://www.roseindia.net/struts/struts2/why-struts2.shtml

New Features of Servlet 2.5 : http://www.javabeat.net/articles/100-new-features-in-servlets-25-1.html

New features of Servlet 3.0 : http://www.javabeat.net/articles/97-new-features-in-servlets-30-1.html

 

Threads : http://javaprepare.com/notes/threads.html

SCJP 6 Kit : http://rapidshare.com/files/209993115/eBook.zip

Understanding Caching in Hibernate : Part 1 – http://blog.dynatrace.com/2009/02/16/understanding-caching-in-hibernate-part-one-the-session-cache/

                                                            Part 2 – http://blog.dynatrace.com/2009/02/16/understanding-caching-in-hibernate-part-two-the-query-cache/

Understanding Web Security using web.xml via Use Cases : http://java.dzone.com/articles/understanding-web-security

 

Free E-Books Download : http://free-ebook-collection.blogspot.com

Spring MVC : http://www.javaworld.com/javaworld/jw-04-2009/jw-04-springmvc.html

Diff b/w App Server n Web Server : http://www.javaworld.com/javaqa/2002-08/01-qa-0823-appvswebserver.html?page=1

Java Internationalization : http://www.developer.com/java/article.php/3826811

Core Java Interview Questions : http://www.j2eebrain.com/java-J2ee-category/interview-questions-faqs/core-java-questions

Configuring Data Source in Tomcat : http://www.java-samples.com/showtutorial.php?tutorialid=943

XPath : http://www.javabeat.net/articles/121-what-is-xpath-1.html

Spring AOP : http://java.dzone.com/articles/introduction-spring-aop

 

How to fix memory leaks in Java : http://java.dzone.com/news/how-fix-memory-leaks-java

Building Multithreaded Java Applications :  http://www.devx.com/Java/Article/41377?trk=DXRSS_LATEST

creating-custom-components-with-struts-2 : http://joshuajava.wordpress.com/2008/12/27/creating-custom-components-with-struts-2/

Advantage and Disadvantages of String Implementation in JAVA : http://www.abcarticledirectory.com/Article/Advantage-and-Disadvantages-of-String-Implementation-in-JAVA/188827

Run JavaScript files on Server Side : http://www.ibm.com/developerworks/library/wa-aj-javaee/

 

Web Application Management : http://java.sys-con.com/node/805374

 

Prometric Site : http://securereg3.prometric.com/

 

Tutorials:

Ejb3 Tutorial : http://docs.jboss.org/ejb3/app-server/tutorial/

Struts Tutorial : http://www.strutstutorial.com/index.html

Struts1, struts2, spring and hibernate Tutorials : http://www.vaannila.com/spring/spring-tutorial/spring-tutorial.html

Servlet, JSP Tutorial : http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/

JSP Tutorial : http://www.jsptut.com/

Servlet Tutorials : http://www.jsptube.com/servlet-tutorials/index.html

Java 5 Tutorial : http://courses.coreservlets.com/Course-Materials/java5.html

http://www.hostitwise.com/java/javaindex.html

Hibernate Tutorial : http://www.hibernatetutorial.com/index.html

http://www.hibernate-training-guide.com/

http://docs.jboss.org/hibernate/stable/core/reference/en/html/tutorial.html

Ajax Tutorial : http://www.learn-ajax-tutorial.com/

http://www.w3schools.com/Ajax/Default.Asp

SQL Tutorial : http://www.sql-tutorial.net/

PL/SQL Tutorial: http://plsql-tutorial.com/

Unix Tutorial : http://www.ee.surrey.ac.uk/Teaching/Unix/unixintro.html

JSTL Introduction: http://www.roseindia.net/jstl/introduction.shtml

UML: http://atlas.kennesaw.edu/~dbraun/csis4650/A&D/UML_tutorial/

http://www.objectmentor.com/resources/articles/umlClassDiagrams.pdf

http://www.cragsystems.co.uk/ITMUML/

Ant: http://supportweb.cs.bham.ac.uk/docs/tutorials/docsystem/build/tutorials/ant/ant.html

http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html

Jdbc : http://www.jdbc-tutorial.com/

                http://www.j2eebrain.com/java-J2ee-category/j2ee-tutorials/jdbc-tutorial

 

Interview Q&A :

http://www.roseindia.net/interviewquestions/

 

Core Java: http://www.techinterviews.com/core-java-interview-questions

http://www.java-interview.com/Core_Java_Interview_Questions.html

http://www.java-interview.com/java_interview_questions.html

http://www.careerride.com/Java-Interview-Questions.aspx (Also go thru the links in left side)

http://www.javacertificate.net/core_java_iqns.htm

http://r4r.co.in/java/faq/index_core_java.shtml

http://www.interview-questions-java.com/

http://www.onesmartclick.com/interviews/java-interview-question.html

http://www.roseindia.net/interviewquestions/corejava/core-java-interview-questions-and-answers.shtml

Servlets: http://www.allappforum.com/interview_questions/servlet_interview_questions.htm

http://www.java-interview.com/servlets_interview_questions.html

http://www.techinterviews.com/servlet-interview-questions

JSP: http://www.techinterviews.com/common-jsp-interview-questions

http://www.careerride.com/JSP-page-life-cycle.aspx

http://www.java-interview.com/jsp_interview_questions.html

http://faq.programmerworld.net/programming/jsp-interview-questions-answers.html

JDBC: http://www.onesmartclick.com/interviews/jdbc-interview-questions-and-answers.html

http://www.java-interview.com/jdbc_interview_questions.html

http://www.careerride.com/JDBC-resultset-types.aspx

http://www.javacertificate.net/jdbc_qns.htm

http://www.techinterviews.com/jdbc-interview-questions-and-answers

Struts: http://www.roseindia.net/interviewquestions/jakartastrutsinterviewquestions.shtml

http://www.java-interview.com/struts_interview_questions.html

http://www.developersbook.com/struts/interview-questions/struts-interview-questions-faqs.php

http://www.techpreparation.com/struts-interview-questions-answers1.htm

http://www.allappforum.com/interview_questions/struts_interview_questions.htm

Springs: http://www.javabeat.net/articles/spring-framework-interview-questions.php

                http://www.coders2020.com/interview/spring_interview_questions

http://www.mydeveloperconnection.com/html/spring-hibernate-QnA.htm

http://www.careerride.com/Spring-Interview-Question.aspx

http://www.java-interview.com/Spring_Framework_Interview_Questions_Page1.html

Hibernate: http://www.developersbook.com/hibernate/interview-questions/hibernate-interview-questions-faqs.php

http://www.java-interview.com/Hibernate_Interview_Questions.html

Tomcat: http://www.java-interview.com/Tomcat_Interview_Questions.html

Weblogic: http://www.java-interview.com/Weblogic_Interview_Questions.html

Design Patterns: http://www.java-interview.com/design_patterns_interview_questions.html

JUnit: http://www.java-interview.com/Junit_Interview_Questions.html

Xml: http://www.java-interview.com/XML_Interview_questions.html

Uml: http://www.java-interview.com/UML_Interview_Questions.html

SQl: http://www.java-interview.com/DB2_SQL_Interview_Questions_Page_1.html

Oracle: http://www.java-interview.com/Oracle_Interview_Questions_Page_1.html

Ant: http://www.java-interview.com/Ant_interview_questions.html

Ajax: http://www.careerride.com/AJAX-Interview-Questions.aspx

                http://www.j2eebrain.com/java-J2ee-ajax-faq.html

                http://www.techinterviews.com/50-javascript-ajax-interview-questions

                http://www.techpreparation.com/ajax-interview-questions-answers1.htm