tag:blogger.com,1999:blog-358978792024-03-14T18:10:28.905+11:00Java-Success BlogJava/JEE blog containing interview questions and answers and tutorialsAnonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.comBlogger477125tag:blogger.com,1999:blog-35897879.post-7943136752425009342014-11-22T00:15:00.000+11:002014-11-22T00:15:30.205+11:00Are you a Java beginner? Why good Java developers are self-taught?Q. Are you a beginner wanting to learn Java?
A. If the answer is yes, read on. You can't learn much with a paid 5 to 10 days or even a 3 month course. It will only set you back on your wallet. Formal education like computer science degree is very valuable and will be well recognized. But, there are a group of people like me who want to make a career transition from other degrees like Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-46941739072951741422014-11-18T10:01:00.000+11:002014-11-18T10:01:41.187+11:00Java exception handling beginner mistakes and best practices a) Sweeping exceptions under the carpet by doing nothing.
try{
//...
}catch(SQLException sqe){
// do nothing
}
In few rare scenarios, it is desired to do nothing with an exception, e.g. in a finally block, you try to close database connection, and some exception occurs. In this case, exception can be ignored.
try{
}catch(SQLException sqe){
//...
}finally{
try{
Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-33840462051645068042014-11-13T22:44:00.001+11:002014-11-16T19:50:12.586+11:00Unix Interview Questions and Answers for Java developersMost commercial Java applications run in a Unix environment. For example, batch jobs. Here are a few Unix questions and answers to test your Unix knowledge.
Q. Can you write a Unix function that parses the command-line arguments?
For example:
<!-- INFOLINKS_OFF -->
process_txns.ksh -env $ENV -backdate 20130125
A. Usually only nine command line arguments can be accessed using Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-89829038016015846592014-10-23T14:15:00.000+11:002014-10-23T14:15:12.503+11:00Debugging and working like a pro with a Java application tutorial with eclipse IDE Often you get to work on a fully functional Java application that is already in production to fix production issues or to enhance its existing functionality. As a new Java developer in the team, it is not easy to get started and contributing. The approach would be slightly different from working on a brand new project. Here are a few tips that will help you hit the road running as quickly as Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-28215139572108980352014-10-22T12:29:00.002+11:002014-10-22T13:34:27.606+11:00Yammer metrics to monitor RESTful web services and report them via its admin webThis is a Yammer metrics tutorial to monitor RESTful web services. This extends RESTEasy web service tutorial basic and the basic stand-alone Yammer tutorial.
Step 1: The pom.xml file needs to have relevant dependencies defined relating to Yammer and Spring Web in addition to the JAX-RS librraies that was covered in the previous tutorial.
<!-- INFOLINKS_OFF -->
<!-- Yammer Metrics --Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-87103784836984731772014-10-10T12:46:00.000+11:002014-10-10T12:46:27.095+11:00When to use which Java collection or data structure? and why?List, Set, Map, and Queue(access the ends FIFO or LIFO) are the basic Java data structure interfaces for which there are different implementations to cater for different usage patterns. Java data structure interview questions are very popular, and pays to know the differences.
#1 Array (Employee[]) Vs List (List<Employee>):
Array is a fixed length data structure whilst a List is a Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-17666087491382617112014-10-01T17:55:00.000+10:002014-10-02T13:23:10.803+10:00How to prepare or train for Java and JEE Job Interviews?What are the core concepts?
If you just rely only on your experience alone, it can take a long time to get a good handle on the core concepts and the 16 key areas. The best way to fast track your career is to proactively learn and apply them.
What are these 16 technical key areas?
Language Fundamentals (LF)
Specification Fundamentals (SF)
Platform Fundamentals (PF)
DesignAnonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com14tag:blogger.com,1999:blog-35897879.post-16949056983332893162014-10-01T12:26:00.000+10:002014-10-01T12:26:19.621+10:00Yammer metrics to monitor RESTful web services with a Servlet filterThis extends Yammer metrics to monitor RESTful web services and report them via its admin web to demonstrate how a Servlet filter can be added to gather metrics for
response codes for 200, 201, 404, etc to get a count.
active requests count
requests timing.
Step 1: Decorate the "HttpServletResponseWrapper" class. HttpServletResponseWrapper is one particular Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-55284040707193674892014-09-02T00:21:00.001+10:002014-09-02T00:21:39.800+10:00Monitoring and gathering statistics with JMX based jconsole and Yammer metricsThis post extends Yammer Metrics with Spring tutorial to demonstrate how the metrics can be monitored for the TradeEngineMain application.
Step 1: Run the TradeEngineMain java class created in the Yammer metrics tutorial.
Step 2: From the DOS command prompt, type jconsole
C:\Users\akumaras>jconsole
Step 3: The jconsole window pops up as shown below.
Step 4: You Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-20279742103549066802014-08-22T12:02:00.000+10:002014-08-22T12:02:15.071+10:00What are the different ways a Java thread gets blocked or suspended? How will you debug Java threading issues?1. It has been put to sleep for a set amount of time
public void run(){
try{
while(true){
this.sleep(1000);
System.out.println("looping while");
}
}catch(InterruptedException ie){
ie.printStackTrace();
}
}
2. The thread is suspended by call to wait( ), and will become runnable on a notify or notifyAll Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-91506124685272722942014-08-08T23:44:00.001+10:002014-08-08T23:50:45.160+10:00What is a volatile variable in Java and when should you use it?
Java Multi-threading Interview Questions and Answers
Beginner Q&A
More beginner Q&A
Beginner locks
Beginner thread communication
Beginner thread sequencing
Intermediate Q&A
Volatile variable
Advanced Q&A
Printing odd and even numbers
Thread pools
ExecutorService
Atomic operations
CountDownLatch and CyclicBarrier
Semaphores and mutexes
Three of the Java Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-30705374321153221082014-08-07T16:24:00.001+10:002014-08-07T16:24:10.949+10:00How to capture user input in Java or interact with user via command line#1: Using the System.console( ) . This will not work within eclipse IDE. You can try it on a DOS or Unix command-line.
package com.user.input;
import java.io.Console;
public class Example1 {
public static void main(String[] args) {
Console console = System.console();
String input = console.readLine("What is your name:");
System.out.println("User input = " + input);
}
}
The Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-84504326500690497022014-08-06T10:03:00.001+10:002014-08-06T10:03:19.647+10:00Top 10 causes of performance issues in JavaCause #1: The JVM spends more time performing garbage collection due to
improper Garbage Collection (GC) configuration. E.g. Young generation being too small.
Heap size is too small (use -Xmx). The application footprint is larger than the allocated heap size.
Wrong use of libraries. For example, XML based report generation using DOM parser as opposed to StAX for large reports generated Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com3tag:blogger.com,1999:blog-35897879.post-85031500069387295562014-08-05T13:47:00.000+10:002014-08-05T13:47:12.440+10:00Java and JSON tutorial converting JSON to object and vice versa with Jackson libraryQ. What is JSON and when to favor it over XML?
A. JSON (JavaScript Object Notation) is a lightweight, text-based, language-netral like XML, but less verbose than XML data exchange format. JSOJ is used in Web services to exchange data between client and server. Client makes ajax requests to get snippets of data in JSON format from the server via RESTful web service calls. JSON is easy for humans Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-81117435346240844942014-08-05T10:33:00.000+10:002014-08-05T10:33:00.080+10:00Java and XSLT tutorial to transform XML documentsQ. What is XSLT?
A. XSLT (Extensible Stylesheet Language Transformations) is a language for transforming XML documents into other XML, HTML, or plain text documents. XSLT is based on functional prgramming ideas, but it is not a full functional programming language as it lacks ability to treat functions as a first class data type. XSLT supports XPath to query parts of XML. The major Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-1027148599928966662014-08-04T18:25:00.000+10:002014-08-04T20:05:34.471+10:00Finding your way around the FIX specification
FIX and Java
FIX tutorial in Java with QuickFIX/j simple example
QuickFix Java example sending and receiving FIX messages
Finding your way around the FIX specification
If you are using FIX spec 4.4 then go to https://fixspec.com/FIX44. The tutorials with QuickFIX/J used NewSingleOrder as the request.
The message has the fields like Tag number.
FIX message for Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-4730495643553620252014-08-04T18:24:00.003+10:002014-08-04T19:26:41.854+10:00QuickFix Java example sending and recieving FIX messages
FIX and Java
FIX tutorial in Java with QuickFIX/j simple example
QuickFix Java example sending and receiving FIX messages
Finding your way around the FIX specification
If you like to work on trading applications, you need to know the FIX protocol and a FIX
engine like QuickFIX/J.
This extends our simple QuickFIX Java example tutorial. This assumes that Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-81644309683441458542014-08-01T18:09:00.003+10:002014-08-01T18:09:47.045+10:00Top 8 things you must know about Java 8 to start coding on the job and talking at the job interviewsAre you ready to get cracking with Java 8 new features? Here are a comprehensive Java 8 features, tutorials, and examples. Drill down into each.
#1: Transforming your thinking from OOP to FOP: One needs to get used to the transformation from imperative programming to functional programming. You like it or not, you will be using functional programming in Java 8, and interviewers Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-60584636323074693912014-08-01T17:17:00.001+10:002014-08-01T17:17:27.112+10:00Java 8 using the Predicate functional interfaceThe java.util.function package in Java 8 has a number of functional interfaces. Let's look at the Predicate<T> interface that is used for filtering objects from a collection. If you are using a Java version pre Java 8 refer Creating sub lists from a list using predicates to filter.
Here is the Java 8 example:
Step 1: Create a Driver domain class using the builder design pattern. Refer HowAnonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-22551787152567557692014-08-01T10:09:00.000+10:002014-08-01T10:09:41.531+10:00Java and XPath tutorial to extract a subset of an XMLQ. What is XPath?
A. XPath is a query language to extract a part of XML document as an SQL is used to extract a part of a database data or a REGEX (i.e. regular expression) is used to extract a part of text. The XPath expressions can return,
XPathConstants.STRING
XPathConstants.NUMBER
XPathConstants.BOOLEAN
XPathConstants.NODE
XPathConstants.NODESET
Here is a very basic example of XPath in Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-82984274500893578362014-07-31T14:22:00.005+10:002014-08-04T19:22:38.931+10:00FIX tutorial in Java with QuickFIX/j simple example
FIX and Java
FIX tutorial in Java with QuickFIX/j simple example
QuickFix Java example sending and receiving FIX messages
Finding your way around the FIX specification
If you like to work on trading applications, you need to know the FIX protocol and a FIX engine like QuickFIX/J.
Q. What is FIX Protocol?
A. FIX stands for Financial Information eXchange, which is an open Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-82618066466745421102014-07-31T10:27:00.001+10:002014-07-31T10:27:28.535+10:00Java and XML tutorial with SAX parser - reading onlyQ. What is a SAX Parser and when will you use it?
A. SAX (Simple API for XML) is a stream oriented API like StAX, but
Unlike StAX, which can read and write, but SAX can only read.
Unlike StAX, which can't validate schema, SAX can perform schema validation.
SAX works by iterating over the XML and call certain methods on a "handler" object , which listens to events like Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-80243863850688157472014-07-30T13:46:00.000+10:002014-07-30T13:46:32.281+10:00Java and XML tutorial with StAX parser - writing cursor based and iterator based
package com.xml;
import java.math.BigDecimal;
import org.springframework.core.style.ToStringStyler;
public class Employee {
private String name;
private String type;
private int age;
private BigDecimal salary;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-33263437789351598142014-07-29T20:02:00.001+10:002014-08-06T18:46:56.716+10:00Why this Java blog? Are you feeling stagnated or finding it hard to get good Java jobs?I can think of 8 reasons
As a journal of my valuable experience for future reference, which otherwise would be lost as Java/JEE technologies, frameworks, libraries, and tools are very vast.
As a motivator to proactively learn, apply, and experience new concepts, frameworks, and tools without feeling stagnated. Just knowing Java alone is never enough in this fiercely competitive market. You needAnonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com0tag:blogger.com,1999:blog-35897879.post-52006493876071912122014-07-29T09:58:00.004+10:002014-07-29T09:58:53.360+10:00Java and XML tutorial with StAX parser - readingQ. What is a StAX Parser and when will you use it?
A. The StAX Java API for XML processing is designed for parsing XML streams, just like the SAX API's, but
StAX is a "pull" API whereas SAX is a "push" API.
StAX can do both XML reading and writing whereas SAX can only do XML reading.
Q. Why use StAX when there is DOM?
A. The DOM parsing involves creating in-memory objects Anonymoushttp://www.blogger.com/profile/00869496028596976417noreply@blogger.com1