Monday, April 30, 2012

Java Introduction:

1 comments
Java is one of object oriented programming language(follows oops concept). It considers the object rather than the procedure and sequence of program. Java is founded by James Gosling and his team(Sun Microsystems,now Sun+oracle) at 1990. Recently James gosling leaves Sun Microsystems(read full story).

Java is used to create many applications and is popular programming language because of its security.

Tuesday, January 25, 2011

How to connect Oracle with servlet - Netbeans step by step guide

2 comments
In this article i am going to guide you to connect the java with Oracle Database in Netbeans.  I'm using Netbeans 6.9.1 and jdk1.6.  Most of J2EE's students struggle with establishing the JDBC connection while doing project work. I hope this article will help for you.

Let's dive into the Procedure:

Sunday, November 21, 2010

Difference between Applet and Application program

0 comments
An applet is client side program which is downloaded in client side and run in the browser.  Applet program can not access network connection like opening socket ,writing to socket. A class extending java.awt.Applet class which has methods like init(), start(), stop(), destroy(),paint() overridden. And cannnot write to client side files i.e. hard disk.


An application runs standalone with a support of virtual machine. An application does not have nay restrictions as Applets have over network and file related activities.They are free to open sockets over a network read and write to a file

Tuesday, November 16, 2010

Write a program to get the Host Name on the basis of IP address

0 comments
import java.net.*;
public class HostName
{
public static void main(String args[])
{

InetAddress inetAddress =InetAddress.getByName("127.64.84.2");//get the host Inet using ip
System.out.println ("Host Name: "+ inetAddress.getHostName());//display the host
}
}

Java short Interview Questions

0 comments
Q.If I am extracting data from database which is have redundancy and not sorted, which collection object will you choose in order to make this data unique and sorted?
A. TreeSet
An Example
import java.util.*;

public class TreeSetExample {

public static void main(final String[] args) {
TreeSet treeset = new TreeSet();
treeset.add("Lincoln");
treeset.add("Clinton");
treeset.add("Obama");
treeset.add("Obama");
treeset.add("Regan");
treeset.add("Washington");
treeset.add("Bush");
System.out.println("TreeSet with Prez:");
Iterator iterator = treeset.iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
System.out.println(object);
}
}
}

The Out put of the program is:

TreeSet with Prez:
Bush
Clinton
Lincoln
Obama
Regan
Washington

Q. Is GC a high priority thread?
A. No, it is low priority thread.

Java Interview Questions

1 comments
  1. Why would you use a synchronized block vs. synchronized method?

    A. A synchronized blocks place locks for shorter periods than synchronized methods.
  2. Can you write a Java class that could be used both as an applet as well as an application?

    A. Yes. Add a main() method to the applet.
  3. Can you call one constructor from another if a class has multiple constructors

    A. Yes. Use this() syntax.

What's the difference between the methods sleep() and wait()

0 comments
A. The code sleep(1000); puts thread aside for exactly one second. The code wait(1000), causes a wait of up to one second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.

Visitors

Followers

 

Java Interview Questions. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com