Skip to main content

Core Points To Remenber in Core Java

  • an empty source file will compile without error
  • if a .java file does not contain a public class or interface it can have any name
  • a single-type import will take precedence over an import-on-demand
  • import-on-demand types do not increase the size of the compiled code ie only the types actually used are added to the code
  • while import-on-demand adds no overhead to the compiled code, they can slow down the speed of the compile
  • a constructor body can include a return statement providing no value is returned
  • any method can throw a Runtime or Error exception without declaring it in the throws clause
  • methods having the same name and parameter types do not have the same signature unless the parameter types are listed in the same order
  • main() can be declared final
  • main() is inherited and can be overridden if not declared as final
  • args[0] references first command line argument after the application name ( arrays in Java are zero-based)
  • main() can be declared public static void ... or static public void ...
  • the variable name does not have to be args; can be anything as long as the type is String[]
  • variables can have the same name as a method or a class
  • only field variables are automatically initialized to their types default value; local variables must be explicitly initialized
  • arrays are initialized to the default value of their type when they are created, not declared, even if they are local variables
  • array index operator [] has highest level of precedence
  • integer variables can be used as array dimension values
  • postfix/prefix operators have the highest level of precedence
  • remember that when the postfix operator is used in an expression, the current value of the variable is used
  • a class may be assigned to an Interface type if the class implements the interface or one of it's sub-interfaces
  • you cannot cast a primitive type to an object reference, or vice versa
  • you cannot cast a boolean type to another primitive type
  • String operations whose result does not alter the original string (ie calling toUpperCase() on a String that is already in uppercase) return the original string reference; otherwise they return a reference to a new String
  • Strings are immutable; the original String value can never be changed
  • all the primitive type wrapper classes override the Object.equals() method to compare the value of the objects; the default Object.equals() method checks if the variables reference the same object
  • you do not have to have a default statement in a switch() block
  • the default statement in a switch() block can appear anywhere in the construct, does not have to be last
  • all sections of the for() loop are optional
  • finalize() can only be executed once on any object

Comments

Popular posts from this blog

Asynchronous Vs. Synchronous Communications

Synchronous (One thread):   1 thread -> |<---A---->||<----B---------->||<------C----->| Synchronous (multi-threaded):   thread A -> |<---A---->| \ thread B ------------> ->|<----B---------->| \ thread C ----------------------------------> ->|<------C----->|

WebSphere MQ Interview Questions

What is MQ and what does it do? Ans. MQ stands for MESSAGE QUEUEING. WebSphere MQ allows application programs to use message queuing to participate in message-driven processing. Application programs can communicate across different platforms by using the appropriate message queuing software products. What is Message driven process? Ans . When messages arrive on a queue, they can automatically start an application using triggering. If necessary, the applications can be stopped when the message (or messages) have been processed. What are advantages of the MQ? Ans. 1. Integration. 2. Asynchrony 3. Assured Delivery 4. Scalability. How does it support the Integration? Ans. Because the MQ is independent of the Operating System you use i.e. it may be Windows, Solaris,AIX.It is independent of the protocol (i.e. TCP/IP, LU6.2, SNA, NetBIOS, UDP).It is not required that both the sender and receiver should be running on the same platform What is Asynchrony? Ans. With messag

Advantages & Disadvantages of Synchronous / Asynchronous Communications?

  Asynchronous Communication Advantages: Requests need not be targeted to specific server. Service need not be available when request is made. No blocking, so resources could be freed.  Could use connectionless protocol Disadvantages: Response times are unpredictable. Error handling usually more complex.  Usually requires connection-oriented protocol.  Harder to design apps Synchronous Communication Advantages: Easy to program Outcome is known immediately  Error recovery easier (usually)  Better real-time response (usually) Disadvantages: Service must be up and ready. Requestor blocks, held resources are “tied up”.  Usually requires connection-oriented protocol