This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Saturday, 1 February 2014

How do I compare strings in Java?

.equals() tests for value equality.
Consequently, if you actually want to test whether two strings have the same value you should use .equals() (except in a few situations where you can guarantee that two strings with the same value will be represented by the same object eg: String interning).
== is for testing whether two strings are the same object.
// These two have the same value
new String("test").equals("test") --> true

// ... but they are not the same object
new String("test") == "test" --> false

// ... neither are these
new String("test") == new String("test") --> false

// ... but these are because literals are interned by
// the compiler and thus refer to the same object
"test" == "test" --> true

// concatenation of string literals happens at compile time,
// also resulting in the same object
"test" == "te" + "st" --> true

// but .substring() is invoked at runtime, generating distinct objects
"test" == "!test".substring(1) --> false
It is important to note that == is much cheaper than equals() (a single pointer comparision instead of a loop), thus, in situations where it is applicable (i.e. you can guarantee that you are only dealing with interned strings) it can present an important performance improvement. However, these situations are rare.

Saturday, 11 May 2013

What Is Hungarian?


Hungarian notation:

It is one of the naming conventions followed by the sun micro system for naming predefined, class/interface/predefined methods and data methods.

Hungarian

Rule 1 for class and interface


"If any class name or interface name", is containing either one word or more than one word. All words first letter must be capital.
EX:


       Normal Notation
          
         Hungarian  Notation
  System
 Action event
Number formal exception array index out  of bounds exception.
  System
  Action event
 Number formal exception array index out of bounds exception.
          

Hungarian Rule 2 for the methods


If any method is containing either one word or more then one word, then one word first letter is small and rest of sub-sequence words first letter must be capital.
EX:

              Normal notation
         Hungarian  notation
  Print/n()
Action perform()
Item state change()
  Print/n()
Action perform()
Item state change()

Hungarian Rule 3 for the methods:

If we are using any predefined data members then all the data member must be  in capital letter.
 If the data member contains more than one word, than they be separated by underscore (-).

               Normal
Hungarian
  PI
MAX-PREORITY
SCROLLBARS-VERTICAL ONLY.
   PI
MAX-PREORITY
SCROLLBARS-VERTICAL ONLY.


The above rules are mandatory for predefined Class/Interface, method and data members.

The above rules are optional for user defined Class/Interfaces, method and data members. Software industry is always recommended to Java programmers apply the Huainan rules even for user defined class/interfaces, methods and data members.

Thursday, 9 May 2013

Difference Between Instance Data Member and Static Data Members

 Types of data members in Java:

We known that every single java program must be written with respect to class, and a class is containing a collection of data members and method. In Java program data members from the class are classified as two types. They are

  1.  Instance data member’s
   2.  static data members

           Instance data members
        Static data members
1. Instance's data members are those whose memory space is creating every single time,"when we create an object."
1. Static data members are those whose memory space is creating only once. When the class is a loader into main memory irrespective of the number of object are created.
2. If the data member of a class is taking a specific value, than we must take the data member as instance.
2. If the data member of a class is taking a specific value, "then we must take the data member as instance."
3. Programatically instance data members declaration should not be preceded by keyword static.
Syntax:-
    Data type V1, V2……….
3. Programmatically instance's  data members declaration should not be preceded by keyword static.
Syntax:
    Data type V1, V2……….
4. Every single instance data member must be access with the respective object name.

Objname.instance data member name
4. All the static data members in Java must be access with the respective class name.

Classname.static data member name
5. All the values of instance data members are not sharable.

5. All the values of static data members are sharable.
6. All the instance data members are known as object's  level data members, because they depend on object name and independent from class name.

EX:- Int PIN,STNO,
6. All the static data members are known as class's  level data members, because they depend on class and independent from object name.

Static string INDIACAP,crsname;

Tuesday, 7 May 2013

Difference Between Class and Object in Java?

Definition of class:- Class is a collection of data members and associated methods.

Definition of object:- Blue print of class is known as object

 

Different between class and object is follow


                    Class
                       Object
1.The process of binding the data member
 and associated methods. In a single unit
  is known as class.
1. Class variable is known as object.
2. Whenever we defined a class we never get any amount of memory space for the data members of class.
2. Whenever we create an object we get the memory space for the data member of a class.
3. Class will have logical existence.
3. Object will have physical existence.
4. Class will be loader first by class. Loader subsystem from secondary memory to primary memory.
4. After loading the class .In main memory object creation will taken place.




All the object of Java resides in heap memory (in general which ever languages follow dynamic memory location whose object resides in heap memory).

All the methods of all the programming languages executes in Stack memory.

All the constants values of all programming languages reside in Associative memory.

Heap memory, Stack memory and Associative memory are the parts of main memory.

Saturday, 4 May 2013

What Is Constructor in Java?

 A constructor is a special member method which will call by the JVM automatically whenever an object is created by placing over own values without placing the default value.

Advantages of constructors:


If we use the constructor concept add a part of over the java program, we get the following advantage.

1. It eliminates in placing default values.

2. It eliminates in calling ordinary method. The purpose of constructor concept is that it initialized  the object.

.

Properties/characteristic of constructor:


 In over the java program, if we want to make use of constructor, the java programmer must follow the rules.

1. Constructor will be called automatically are implicitly whenever an object is created.

2. Constructor name must be similar to class name.

3. Constructor will not return any value even void also (if we write any return type in java, which is by default treated as an ordinary method).

4. The modified of the constructor should not be static because constructor will be called each time as a when an object is created...

5. Constructor will not be inherited because each constructor of class must initialize its own data member.

6. A constructor of a class may are may not be private.

7. If the constructor is private than the object of corresponding class can’t be created within the context of some other class, but it can be possible to create it object only within the context scope of class.

8. If a constructor is not private than the corresponding class object can be created everywhere i.e. no restriction on the accessibility of the constructor.

Thursday, 2 May 2013

What Is Different Between Instant Methods and Static Methods?


Each and every class of java contains a collection of methods the methods of java are divided into two types. They are

1. Instance methods/non static methods.

2. Static methods.


                    Instant methods
                   Static methods
1. Instance methods are those, which are recommended to perform Repeated operations such as reading the records from the file, reading records from the data base.

1. Static methods are those, which are recommended to perform. One time operation such as obtaining connection from the data base opening the file either in read mode or write mode.
2. Pro-grammatically, instance methods definition should not be preceded by a keyword.

Static

 Syntax

  Return type method name(list of formal parameter)
{
      block of statements()
}

2. Pro-grammatically, static methods definition must be preceded by a keyword static.

Syntax

  Static return type method name(list of formal parameters)

{

     Block of statements()
}



3. Each and every instances method in java must be axis with respective to object name objname instance method name.

3. Each and every static method in java must be axis with respective to class name
Class name Static method name.

4. The result of instance is not sharable.

4. The result of static method is sharable.

5. Instance method is also known as object level methods because they depend on object name and independent form class name.

Example:

Void calfot()
{

   tot=m1+m2+M3;
}
5. Static methods are also known as class level method because they depend on class name and independent on object name.

Example:

Static void main(string arrays)
{

    S1,caltotal();
   S2.caltotal();
}


6. ISR is only executed when the interrupt is trigger.



6. function is only executed when the function caller called the function.

7 function call the arguments, local  variable and return address is stored in the stack.


7. ISR after execution the current instruction the context is saved with no return value.



Tuesday, 30 April 2013

What Are the Features of Java?

Features of any Programing language are nothing, but the service or the basic facilities Provided by the language to the Industry program for the development of Real-World application.

The Java Programing language Provides thirteen(13) Features:


1. Simple

2. Platform Independent

3. Architecture neutral

4. Portable

5. Multi threaded

6. Network

7. Distributed

8. High performance

9. Robust (strong)

10. Interpreted

11. Dynamic

12. Secured

13. Object Oriented Programing

Simple:


Java is of the simple programing language, because of the following factors.

The language Java doesn't support the concept of pointers that is  java language is Free From pointer. Hence we get less application development time and less application execution time because of the magic of byte code.

 

Platform independent:


A platform Independent language oblique technology is one whose related application run on every operating system without considering their vender.
Architectural Neutral:

An Architectural Neutral  application is those, which are running on every processor without considering These Vendors and Artie.

 

Portable:


A portable application is one, which runs on every operating system  and processor without considering Archie and vendors.

The applications of C,C++,Pascal,cobalt, etc. are treated as Non-portable application.

The applications of java are by default portable, according to  the sun micro system portability is equal to platform independent plus architectural  neutral.

                                                    portable=P.I+A.N

Industry is always recommended to develop the distributed application with portable technology only but not by non-portable technology, because the developer needed not to spend many amounts of time to write a special programing to run of every operating system   on  a processor.

 

Multi threaded:


The basic aim of multi threading is to achieve concurrent execution. A flow of control is known as thread. The basic purpose of thread is to execute user defined methods. IF a java program is containing multiple flow of control than that java program is known as Multi threaded.

 

Network:


The basic aim of networking is to share the data between multiple machine, which are located either in same network or in the different network.

A Network is a collection of " inter connected Atamous/non autonomous computer connected to the server."

 

Distributed: 


According to industry standards, every Java application is distributed application, based on the running process of the java project java projects are classified into two types.

They are 1.Centralized application 2. Distributed application

A centralized application is one, which run within the context of single server, and it can be access across the global by authorized people.

Example is SBI application.

Distributed application is one, which run within the context of multiple servers, and it can be access as across the globe by both authorize and unauthorized people.

Example is Yahoo.

 

High performance:


Java is one of the high-performance languages because of the following factors.

1. Magic of byte code.

2 Inbuilt garbage collection.

The above two factors given by sun

 

Robust (strong):


When ever we write any program in any language, we get two types of errors, these compile time error and Run time error.

Compile time error are those which are listed during  of the program provided. The Programmer is not following the syntax of the language.

Run time error are those which occur during execution of the program provide the normal user enter invalid input.

Run time error in the java program are known as exception.

The basic advantage of java language is that, it can handle all types of Run-time errors, and it gives as a suitable message to the normal user.

 

Interpreted:


In the older version of java compilation phase is very faster and interpreted phase is slow ,this one of the complain given by an industry programmer to the sun micro system.

Sun micro system as return a program like JIT(just in time compiler) and added a part of JVM to speed up the interpreted phase by reading the entire section of byte code and converting into native understanding form of OS. Hence in the current version of java interpreted  phase is very fast than compilation phase of java. Sun micro system has populated java is one of highly interpreted programing language.

 

Dynamic:


If we write any program during its run time whatever input, we are entire, that input must be stored in main memory of computer by allocating sufficient memory space the memory can be allocated in any program language in two ways.

There are

1.Static/compile time memory allocation.

2. Dynamic /run time memory allocation.

Java program language never follows static memory allocation, but it always follows dynamic memory allocation but making New Operation.

Since java is following dynamic memory location sun micro system has populated, it is as one of the Dynamic program languages.

 

Secured:


Security is one of the principles invented by industry expert to prevent the confidential information from an unauthorized user.

Monday, 29 April 2013

What Is Different Between FTP and HTTP? What Is Stateless and State Full Protocols?

                    FTP

                   HTTP

1. It is one of Protocol comes under UDP.

1. It is one of protocol comes under TCP.
2. FTP is of the non acknowledgment oriented protocol.

2. Http is of the acknowledgement oriented protocol.

3. FTp is one of the state full Protocol.

3. Http is of the stateless protocol.

4. FTP is use in low level application (other than internet Application).

4. Http is used in high level Application ie internet Application.

Definition of Stateless Protocol:


A stateless Protocol is one ,which maintains an identity of the client for a limited spam of time.

Example of stateless protocol:

HTTP

Definition of Sate full Protocol:


A State full  protocol is One, which maintain an Identity of client Forever.


Example of State-full Protocol:

FTP

Twitter Delicious Facebook Digg Stumbleupon Favorites More