Powered by Blogger.

Download HeadFirstServlets Chapter - 3 Mini MVC Tutorial

>> Monday, November 29, 2010



Download the HeadFirstJava - Chapter-3 ..Mini MVC Tutorials..

The Continuous Download of the Chapter - 2.

Struts Meterials from DURGA SOFT download.

>> Friday, November 19, 2010



  • Architecture
    • 2-tier Architecture
    • 3-tier Architecture
    • n-tier Architecture
  • Web Application development models
    • MODEL1 Based Web Applications
    • MODEL2 Based Web Applications
  • Struts Introduction
  • ActionForm and Action Classes
  • Struts Flow/Struts Architecture
  • DesignPatterns
    • MVC(Model View Controller)
    • Singleton DesignPattern
    • FrontController DesignPattern
    • ApplicationController DesignPattern
    • DataTransforObect/ValueObject DesigenPattern

Example to find maxmimum element in a Vector

>> Sunday, October 17, 2010

Example to find maximum element in a Vector

This java example shows how to find a maximum element of Java Vector using max method of Collections class.To find maximum element of Java Vector use, static Object max(Collection c) method of Collections class.

This method returns the maximum element of Java Vector according to its natural ordering.

    import java.util.Vector;
    import java.util.Collections;

    public class FindMaximumOfVectorExample {
     public static void main(String[] args) {

     //create a Vector object
     Vector v = new Vector();
     //Add elements to Vector
 
     v.add(new Double("324.4324"));
     v.add(new Double("345.3532"));
     v.add(new Double("342.342"));
     v.add(new Double("357.349"));
      v.add(new Double("23.32453"));

      Object obj = Collections.max(v);
     System.out.println("Maximum Element of Java Vector is : " + obj);

     }
    }


The Output is:

Maximum Element of Java Vector is : 357.349

Reference Books:

Example to Find maxmimum element in ArrayList

Example to Find maxmimum element in ArrayList

This java example shows how to find a maximum element of Java ArrayList using max method of Collections class.

To find maximum element of Java ArrayList use, static Object max(Collection c) method of Collections class.
This method returns the maximum element of Java ArrayList according to its natural ordering.

import java.util.ArrayList;
    import java.util.Collections;

    public class FindMaximumOfArrayListExample {

     public static void main(String[] args) {

     //create an ArrayList object
     ArrayList arrayList = new ArrayList();

     //Add elements to Arraylist
     arrayList.add(new Integer("327482"));
     arrayList.add(new Integer("13408"));
     arrayList.add(new Integer("802348"));
     arrayList.add(new Integer("345308"));
     arrayList.add(new Integer("509324"));

     Object obj = Collections.max(arrayList);
     System.out.println("Maximum Element of Java ArrayList is : " + obj);

     }
    }

The Output :

Maximum Element of Java ArrayList is : 802348

Reference Books: 

Create a List containing n Copies of Specified Object

Create a List containing n Copies of Specified Object This java example shows how to create a list consisting n copies of specified copies using nCopies method of Collections class.

To create a List containing n copies of specified Object use static List nCopies(int n, Object obj) method of Java Collection class.This method returns immutable List containing n copies of the specified Object.
List Containing N copies of Specified Object_JavabynataraJ

Enumerate Vector using java.util.Enumeration

Enumerate through a Vector using Java Enumeration Example.This Java Example shows how to enumerate through elements of a Vector using Java Enumeration.

Enumeration provides two methods to enumerate through the elements. It's hasMoreElements method returns true if there are more elements to enumerate through otherwise it returns false. Its nextElement method returns the next element in enumeration.

static ArrayList list(Enumeration e) method of Collections class. This method returns the ArrayList containing the elements returned by specified Enumeration object in order they are returned.

    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Enumeration;
    import java.util.Vector;

   public class CreateArrayListFromEnumerationExample {
   public static void main(String[] args) {
   //create a Vector object
   Vector v = new Vector();
   //Add elements to Vector

   v.add("A");
   v.add("B");
   v.add("D");
   v.add("E");
   v.add("F");
   
   System.out.println("Vector contains : " + v);
   //Get Enumeration over Vector
   Enumeration e = v.elements();
   //Create ArrayList from Enumeration of Vector
   ArrayList aList = Collections.list(e);
   System.out.println("Arraylist contains : " + aList);

  }
 }

Output is:

Vector Contains : [A, B, D, E, F]
Arraylist contains : [A, B, D, E, F]

Reference Books:

Copy Elements of Vector to Java ArrayList Example

  1. /*
  2. Copy Elements of Vector to Java ArrayList Example
  3. This java example shows how to copy elements of Java Vector to Java ArrayList using
  4. copy method of Collections class.
  5. */
  6. import java.util.ArrayList;
  7. import java.util.Collections;
  8. import java.util.Vector;
  9. public class CopyElementsOfVectorToArrayListExample {
  10. public static void main(String[] args) {
  11. //create a Vector object
  12. Vector v = new Vector();
  13. //Add elements to Vector
  14. v.add("1");
  15. v.add("2");
  16. v.add("3");
  17. //create an ArrayList object
  18. ArrayList arrayList = new ArrayList();
  19. //Add elements to Arraylist
  20. arrayList.add("One");
  21. arrayList.add("Two");
  22. arrayList.add("Three");
  23. arrayList.add("Four");
  24. arrayList.add("Five");
  25. /*
  26. To copy elements of Java Vector to Java ArrayList use,
  27. static void copy(List dstList, List sourceList) method of Collections class.
  28. This method copies all elements of source list to destination list. After copy
  29. index of the elements in both source and destination lists would be identical.
  30. The destination list must be long enough to hold all copied elements. If it is
  31. longer than that, the rest of the destination list's elments would remain
  32. unaffected.
  33. */
  34. System.out.println("Before copy ArrayList Contains : " + arrayList);
  35. //copy all elements of Vector to ArrayList using copy method of Collections class
  36. Collections.copy(arrayList,v);
  37. /*
  38. Please note that, If ArrayList is not long enough to hold all elements of
  39. Vector, it throws IndexOutOfBoundsException.
  40. */
  41. System.out.println("After Copy ArrayList Contains : " + arrayList);
  42. }
  43. }
  44. /*
  45. Output would be
  46. Before copy ArrayList Contains : [One, Two, Three, Four, Five]
  47. After Copy ArrayList Contains : [1, 2, 3, Four, Five]
  48. */

Copy Objects from One Vector to Another Vector using Java

Copy Elements of One Java Vector to Another Java Vector Example

This java example shows how to copy all elements of one Java Vector object to
another Java Vector object using copy method of Collections class.

Copy Elements of ArrayList to Vector Example

Copying ArrayList elements from Vector is so simple by using predefined method in Collections class.
Collections.copy(vector,arrayList);
Java Collections_ArrayList to Vector Example_JavabynataraJ
/*This java example shows how to copy elements of Java ArrayList to Java Vector using
copy method of Collections class.
*/

Copy Elements from one ArrayList to Another ArrayList

Here is the Program to copy the values from one ArrayList to another ArrayList.

package collect;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;


public class ListClas {
 public static void main(String[] args) {

  List l1=new ArrayList(); 
  
  l1.add("hi");
  l1.add("brother");
  
  ArrayList al=new ArrayList(); 
  al.add("hello");  
  al.add("guru");   
  
  Collections.copy(al,l1);   
  Iterator i= al.iterator();  
  
  while(i.hasNext()){ 
   i.hasNext();  
   System.out.print(" "+i.next()); 
   //System.out.println(al);  
  }   
 }  
}

This is the procedure to copying the objects from one list to another.

For Java References:
Effective Java (2nd Edition) 

DeployingWAR FileWith Sun Java SystemApplication Server

>> Saturday, October 16, 2010

After you install Directory Server Enterprise Edition, you can deploy theWARfile to access
DSCC. The following procedure contains the deployment instructions to deploy theWARfile:

▼ To DeployWAR FileWith Sun Java SystemApplication

Server
Create theWAR file for DSCC.

$ install-path/bin/dsccsetup war-file-create
For native packages installation, theWARfile is created in the /var/opt/SUNWdsee7/ directory.
For zip distribution installation, theWARfile is created in the install-path/var directory.
Initialize the DSCC registry.

$ install-path/bin/dsccsetup ads-create
Choose password for Directory Service Manager:
Confirm password for Directory Service Manager:
Creating DSCC registry...
DSCC Registry has been created successfully
To create server instances on the same host where DSCC is deployed, register the DSCC agent in
CommonAgent Container.
$install-path/bin/dsccsetup cacao-reg
Type the following command to check the location and other statistics of yourWARfile and
DSCC registry:
$ install-path/bin/dsccsetup status
Create an application server instance.
$ mkdir /local/domainroot
$ cd app-server-install-path/bin
$ asadmin create-domain --domaindir /local/domainroot --adminport 3737 \
--user admin dscc7
Edit the server.policy file.
a. Open the server.policy file.
$ vi /local/domainroot/dscc7/config/server.policy
1
2
3
4
5
DeployingWAR FileWith Sun Java System Application Server
Sun Directory

b. Add the following statements to the end of the file:
// Permissions for Directory Service Control Center
grant codeBase "file:${com.sun.aas.instanceRoot}/applications/j2ee-modules/dscc7/-"
{
permission java.security.AllPermission;
};
The addition configures the application server to grant all the Java permissions to the DSCC
application.

Deploy theWAR file in your application server instance.

$ asadmin start-domain --domaindir /local/domainroot --user admin dscc7
$ cp install-path/var/dscc7.war /local/domainroot/dscc7/autodeploy
For more information about creating and configuring application server instances and
deploying theWARfile, refer to the Sun Java System Application Server OnlineHelp.
Open DSCC.
Use http://hostname:8080/dscc7 or https://hostname:8181/dscc7 based on the
configuration of your application server.
The Directory ServiceManager Login page displays.

click here to download the fulll pge

What is Normalization..?How many types are there.?

>> Sunday, October 10, 2010


Normalization:

Normalization is a design technique which helps to design the relational database.
Normalization is essentially a two step process that puts data into tabular form by removing redundant data from the relational tables.

Normalization has been divided into following types.

1.First Normal Form (1NF): A Relational table all column values are atomic.It means that it contains no repeating values.

(or)

A Relational table should not be any multivalued column.

2.Second Normal Form (2NF) : A Relational table is in second normal form if it is in First Normal form and every Non-Key Column is fully dependent on PrimaryKey.

(or)

The table should be in 1NF and every non key column must fully functional dependent on primaryKey.

3.Third Normal Form (3NF): A Relational table is in third Normal Form (3NF) if it is already in 2NF and every non-key column is non transitive dependent upon its primary key.

(or)

The table should be in 2NF and every non-key column should not be any transitive dependencies.

4.Boyce Codd Normal Form (BCNF) : The Relational table is in BCNF if it is already in 3NF and every non key column should not be overlapping between candidate keys.

(or)

The table should be in 3NF and the columns should not be overlapping between any candidate keys.

Java Interview Questions on Package and Interface

>> Wednesday, September 29, 2010

Interview Questions on Package and interface in Java

1) What are packages ? What is use of packages ?

Ans :The package statement defines a name space in which classes are stored.If you omit the package, the classes are put into the default package.
Signature... package pkg;
Use: * It specifies to which package the classes defined in a file belongs to. * Package is both naming and a visibility control mechanism.

2) What is difference between importing "java.applet.Applet" and "java.applet.*;" ?

Ans :"java.applet.Applet" will import only the class Applet from the package java.applet
Where as "java.applet.*" will import all the classes from java.applet package.

3) What do you understand by package access specifier?

Ans : public: Anything declared as public can be accessed from anywhere
private: Anything declared in the private can’t be seen outside of its class.
default: It is visible to subclasses as well as to other classes in the same package.

4) What is interface? What is use of interface?

Ans : It is similar to class which may contain method’s signature only but not bodies.
Methods declared in interface are abstract methods. We can implement many interfaces on a class which support the multiple inheritance.

5) Is it is necessary to implement all methods in an interface?

Ans : Yes. All the methods have to be implemented.

6) Which is the default access modifier for an interface method?

Ans : public.

7) Can we define a variable in an interface ?and what type it should be ?

Ans : Yes we can define a variable in an interface. They are implicitly final and static.

8) What is difference between interface and an abstract class?

Ans : All the methods declared inside an Interface are abstract. Where as abstract class must have at least one abstract method and others may be concrete or abstract.
In Interface we need not use the keyword abstract for the methods.

9) By default, all program import the java.lang package.

True/False

Ans : True

10) Java compiler stores the .class files in the path specified in CLASSPATH environmental variable.

True/False

Ans : False


11) User-defined package can also be imported just like the standard packages.

True/False

Ans : True

12) When a program does not want to handle exception, the ______class is used.

Ans : Throws

13) The main subclass of the Exception class is _______ class.

Ans : RuntimeException

14) Only subclasses of ______class may be caught or thrown.

Ans : Throwable

15) Any user-defined exception class is a subclass of the _____ class.

Ans : Exception

16) The catch clause of the user-defined exception class should ______ its Base class catch clause.

Ans : Exception

17) A _______ is used to separate the hierarchy of the class while declaring an Import statement.

Ans : Package

18) All standard classes of Java are included within a package called _____.
Ans : java.lang

19) All the classes in a package can be simultaneously imported using ____.

Ans : *

20) Can you define a variable inside an Interface. If no, why? If yes, how?

Ans.: YES. final and static

21) How many concrete classes can you have inside an interface?

Ans.: None

22) Can you extend an interface?

Ans.: Yes

23) Is it necessary to implement all the methods of an interface while implementing the interface?

Ans.: No

24) If you do not implement all the methods of an interface while implementing , what specifier should you use for the class ?

Ans.: abstract

25) How do you achieve multiple inheritance in Java?

Ans: Using interfaces.

26) How to declare an interface example?

Ans : access class classname implements interface.

27) Can you achieve multiple interface through interface?

a)True
b) false

Ans : a.

28) Can variables be declared in an interface ? If so, what are the modifiers?

Ans : Yes. final and static are the modifiers can be declared in an interface.

29) What are the possible access modifiers when implementing interface methods?

Ans : public.

30) Can anonymous classes be implemented an interface?

Ans : Yes.

31) Interfaces can’t be extended.

a)True

b)False

Ans : b.

32) Is it possible to use few methods of an interface in a class ? If so, how?

Ans : Yes. Declare the class as abstract.

SCJP 5.0 meterials and ebooks Download

>> Saturday, September 18, 2010

SCJP Certification of Srikanth Pagada_JavabynataraJ

Hello friends,

I have the materials of Scjp 4.0,Scjp 5.0 ebooks .I like to share with you guys. I am giving the links of these two scjp books in a zip file format.It contains 17 or 18 chapters with those two books.

These books are enough to prepare the scjp certification.But you should be very careful and understand what you are reading.

Ok.Guys All the Best.

Download here Scjp 4.0

Download here Scjp 5.0
Reference Books:

Java Interview Questions by Nageswara Rao

>> Friday, September 10, 2010

The famous java lecturer Nageswara Rao from InetSolv Ameerpeta, Hyderabad has written java interview Questions. Also he written several books on Core Java and J2EE technologies.
You may be an experienced Java developer with hand on experience in core development or you may be a fresher who is looking for an entry in java job market, if you want to hit the job market , you may need to refresh some of the basic java terms or you may need to know what are the commonly asked questions to prepare yourself to for java technical interview.
Java interview Questions-JavabynataraJYou as an experienced java developer, just need to refresh your knowledge on java. But you as a fresher may need to know what can be the possible questions , what are the commonly asked questions, what are the valid answers for these questions and so on.

Different types of Design Patterns

>> Friday, June 18, 2010

Software Engineers and Developers choose a design pattern to start a project using particular design pattern to start a project. These are helpful to solve the Specific coding and design problems in the real time projects.
Design Patterns also called as Reusable Object Oriented Software.
These are the different types of design patterns used in real time world to develop projects.
Different Types of design patterns_JavabynataraJ

Collections Hirarchy

>> Friday, May 28, 2010

 
Collections Hirarchy diagram

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.