JavaBeat

  • Home
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Privacy

How To Use The Palindrome Function In Java – Methods And Examples

October 26, 2018 by Krishna Srinivasan Leave a Comment

How To Use The Palindrome Function in Java

You know what a palindrome is, right?

A palindrome is a phrase or sentence that reads the same forward and backward, such as “Madam, I’m Adam” or “dammit I’m mad” or “a man, a plan, a canal, Panama.”

Quick Navigation
Longest Palindromic Substring
Manacher’s Algorithm and Palindrome Function in Java
Examples of Palindrome Function in Java
Manacher’s Algorithm: Case in Point
Some Final Thoughts About Palindrome Function in Java

Longest Palindromic Substring

Computer science goes into the concept of longest palindromic substring, or longest symmetric factor. This is the problem of finding the longest substring of any string that also reads as a palindrome.

Consider the word “bananas” – the “anana” of that is a palindrome. In the word “abracadabra,” the entire word isn’t a palindrome but “aca” and “ada” within that word are palindromic. When taking this approach, it’s sometimes necessary to look at all palindromic substrings that stand alone and can’t be extended or connected to other, longer palindromic substrings.

In the 70s, Glenn Manacher developed an algorithm and set of rules for palindromes that appear at the start of any given string. Later researchers found that this same algorithm can be used to determine all palindromic substrings anywhere in the original input string (both of these are linear time solutions).

Manacher’s Algorithm and Palindrome Function in Java

This algorithm can be considered as a set of ground rules for observations and characteristics of a palindrome and sub-palindrome:

  • When considering palindrome function in Java, the left side of a palindrome must be the mirror image of the right side
  • A third palindrome that is within the right side of a first palindrome will be the exact same length as a second palindrome that’s positioned at the center on the left side. That is, if the second palindrome is still within the limits of the first palindrome by one character, or doesn’t extend to the left bound of the first palindrome
  • When a second palindrome meets up with or goes beyond the left bound of the first palindrome, the interval from the center of the second palindrome to the left bound of the first should be exactly equal to the interval from the third palindrome’s center to the first palindrome’s right bound
  • In an example like that above, the third palindrome’s length can be determined as the next character after the character at the right bound of the first palindrome. It can then be compared with its mirror character at the third palindrome’s center
  • When determining the palindromic length of a fourth palindrome, when its center is outside the right bound of the first palindrome, neither the first nor second palindrome can be used to determine that length
  • When determining the palindromic length of a substring, the first palindrome can be thought of as a reference with characters farthest to the right in a string

Examples of Palindrome Function in Java

Let’s say that s is a string of N characters. In this case, s2 can be considered a derived string of s, with N * 2 + 1 elements.

Each element should correspond to one or more of the following:

  • The N characters in s
  • The N-1 boundaries among these characters
  • Any boundaries before or after the first and last character

A boundary in s2 can be considered equal to any other boundary in s2, when it comes to matching elements and determining palindromic length. For the array of palindromic span for the elements in s2, from center to either outermost bound, each boundary should be counted toward palindromic length.

In other words, a palindrome that has a palindromic span of 1 would be three elements in length. This would be represented as p in our example.

For the position of the center of the palindrome that includes a boundary closest to the right bound of s2, that will be represented by c in our example, i.e. p[c]*2+1. The position of the rightward boundary of this palindrome will be represented by r, i.e. r = c+p[c]. For the position of a character or boundary in s2 with a palindromic span that has yet to be determined, that should be represented by i in our example, with i always being to the right of c. i2, then, is the mirrored position of i around c, i.e. {i, i2} = {6,4}, {7,3}, {8,2}, when c = 5

Manacher’s Algorithm: Case in Point

char[] s2 = addBoundaries(s.toCharArray());

int[] p = new int[s2.length];

int c = 0, r = 0; // Here the first element in s2 has been processed.

int m = 0, n = 0; // The walking indices to compare if two elements are the same

for (int i = 1; i<s2.length; i++) {

if (i>r) {

p[i] = 0; m = i-1; n = i+1;

} else {

int i2 = c*2-i;

if (p[i2]<(r-i-1)) {

p[i] = p[i2];

m = -1; // This signals bypassing the while loop below.

} else {

p[i] = r-i;

n = r+1; m = i*2-n;

}

}

while (m>=0 && n<s2.length && s2[m]==s2[n]) {

p[i]++; m--; n++;

}

if ((i+p[i])>r) {

c = i; r = i+p[i];

}

}

int len = 0; c = 0;

for (int i = 1; i<s2.length; i++) {

if (len<p[i]) {

len = p[i]; c = i;

}

}

char[] ss = Arrays.copyOfRange(s2, c-len, c+len+1);

return String.valueOf(removeBoundaries(ss));

}

private static char[] addBoundaries(char[] cs) {

if (cs==null || cs.length==0)

return "||".toCharArray();

char[] cs2 = new char[cs.length*2+1];

for (int i = 0; i<(cs2.length-1); i = i+2) {

cs2[i] = '|';

cs2[i+1] = cs[i/2];

}

cs2[cs2.length-1] = '|';

return cs2;

}

private static char[] removeBoundaries(char[] cs) {

if (cs==null || cs.length<3)

return "".toCharArray();

char[] cs2 = new char[(cs.length-1)/2];

for (int i = 0; i<cs2.length; i++) {

cs2[i] = cs[i*2+1];

}

return cs2;

}

}

Determining If a String is a Palindrome

In these cases, each character can be looped and checked against the character on the opposite side. The problem with this approach is that half the work is unnecessary, as each character is being checked twice.

In the English palindrome “madam,” the algorithm would check each letter as a character, when all that really needs to be compared are the first two characters and last two characters – the middle one would not need to be checked.

Checking for Palindrome String Using Recursion (Courtesy Beginnersbook)

package beginnersbook.com;

import java.util.Scanner;

class PalindromeCheck

{

//My Method to check

public static boolean isPal(String s)

{ // if length is 0 or 1 then String is palindrome

if(s.length() == 0 || s.length() == 1)

return true;

if(s.charAt(0) == s.charAt(s.length()-1))

/* check for first and last char of String:

* if they are same then do the same thing for a substring

* with first and last char removed. and carry on this

* until you string completes or condition fails

* Function calling itself: Recursion

*/

return isPal(s.substring(1, s.length()-1));

/* If program control reaches to this statement it means

* the String is not palindrome hence return false.

*/

return false;

}

public static void main(String[]args)

{

//For capturing user input

Scanner scanner = new Scanner(System.in);

System.out.println("Enter the String for check:");

String string = scanner.nextLine();

/* If function returns true then the string is

* palindrome else not

*/

if(isPal(string))

System.out.println(string + " is a palindrome");

else

System.out.println(string + " is not a palindrome");

}

}

Output 1:

Enter the String for check:

qqaabb

qqaabb is not a palindrome

Output 2:

Enter the String for check:

cocoococ

cocoococ is a palindrome

Some Final Thoughts About Palindrome Function in Java

 Palindrome Function in Java

To sum up, your task with palindromes is to compare characters at the left and right ends of a string. If they don’t match, the string itself isn’t a palindrome. The next step is to compare the two characters that are second to the left and right ends of a string, then continue toward the center of the string or until you find a pair that don’t match.

If you reach the middle of the string, then you do have a palindrome – or at least part of that string can be considered a palindrome. If the string is “madam,” the entire string is a palindrome. If the string is “amadam,” it’s not a palindrome but the “ada” toward the center can be considered as a palindrome.

Filed Under: Java Tagged With: palindrome function, palindrome function in Java

Write To File In Java: Best Ways And Other Approaches For Writing

October 25, 2018 by Krishna Srinivasan Leave a Comment

 Write To File In Java

Best Ways to Write to File in Java

For programmers writing in Java who need to do a Java write to file, there are four main ways to accomplish this: FileWriter, BufferedWriter, java 7 Files and FileOutput Stream. We’ll touch on all of those today.

Here’s a brief overview, and we’ll expand on each of these as we go along:

Quick Navigation
Best Ways to Write to File in Java
FileWriter
BufferedWriter
FileOutputStream
Files
Other Approaches for Writing to File
Input streams 
BufferedWriter 
PrintWriter 
Don’t Forget When You’re Doing a Java Write to File

FileWriter

Since it’s the simplest way to write a file in Java, FileWriter is one of the most popular methods. It allows the programmer to write String to the file and write byte array, thanks to overloaded write method. FileWriter also allows for writing part of the String or byte array. Since FileWriter writes directly to files, it should be used when the number of writes are lower.

BufferedWriter

BufferedWriter has many similarities to FileWriter, with the exception of an internal buffer for writing data into File. If the actual number of write operations is greater, the IO operations will be fewer, with enhanced performance. This is what makes BufferedWriter a better choice when there’s a great number of write operations to be done.

FileOutputStream

When there’s a great deal of raw stream data to be written to file, FileOutputStream is a great choice. FileWriter and BufferedWriter are great for writing text to file, but FileOutputStream is certainly better for these applications.

Files

Java 7 was the debut of Files utility class, and its OutputStream is designed to write byte array into file.

Java Write to File Example (courtesy of journaldev.com)

Here’s an example of a standard method to write to file in java:

package com.journaldev.files;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileOutputStream;

import java.io.FileWriter;

import java.io.IOException;

import java.io.OutputStream;

import java.nio.file.Files;

import java.nio.file.Paths;

public class WriteFile {

/**

* This class shows how to write file in java

* @param args

* @throws IOException

*/

public static void main(String[] args) {

String data = "I will write this String to File in Java";

int noOfLines = 10000;

writeUsingFileWriter(data);

writeUsingBufferedWriter(data, noOfLines);

writeUsingFiles(data);

writeUsingOutputStream(data);

System.out.println("DONE");

}

/**

* Use Streams when you are dealing with raw data

* @param data

*/

private static void writeUsingOutputStream(String data) {

OutputStream os = null;

try {

os = new FileOutputStream(new File("/Users/pankaj/os.txt"));

os.write(data.getBytes(), 0, data.length());

} catch (IOException e) {

e.printStackTrace();

}finally{

try {

os.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

/**

* Use Files class from Java 1.7 to write files, internally uses OutputStream

* @param data

*/

private static void writeUsingFiles(String data) {

try {

Files.write(Paths.get("/Users/pankaj/files.txt"), data.getBytes());

} catch (IOException e) {

e.printStackTrace();

}

}

/**

* Use BufferedWriter when number of write operations are more

* It uses internal buffer to reduce real IO operations and saves time

* @param data

* @param noOfLines

*/

private static void writeUsingBufferedWriter(String data, int noOfLines) {

File file = new File("/Users/pankaj/BufferedWriter.txt");

FileWriter fr = null;

BufferedWriter br = null;

String dataWithNewLine=data+System.getProperty("line.separator");

try{

fr = new FileWriter(file);

br = new BufferedWriter(fr);

for(int i = noOfLines; i>0; i--){

br.write(dataWithNewLine);

}

} catch (IOException e) {

e.printStackTrace();

}finally{

try {

br.close();

fr.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

/**

* Use FileWriter when number of write operations are less

* @param data

*/

private static void writeUsingFileWriter(String data) {

File file = new File("/Users/pankaj/FileWriter.txt");

FileWriter fr = null;

try {

fr = new FileWriter(file);

fr.write(data);

} catch (IOException e) {

e.printStackTrace();

}finally{

//close resources

try {

fr.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

Other Approaches for Writing to File

There are actually a multitude of methods for writing to file when it comes to Java. Each has its advantages and pitfalls, and the variety of methods can make it quite confusing.

Input streams 

​Writing input streams is the simplest and most direct way to write data into files for Java.

Here’s an example, courtesy octoperf.com:

package com.octoperf;

import com.google.common.io.Closer;

import org.junit.Rule;

import org.junit.Test;

import org.junit.rules.TemporaryFolder;

import java.io.BufferedOutputStream;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileOutputStream;

import java.io.FileWriter;

import java.io.IOException;

import java.io.PrintWriter;

import java.io.Writer;

import static com.google.common.base.Charsets.UTF_8;

public class JavaWriteFileTest {

private static final String HELLO_WORLD = "Hello World!";

private static final String OUT_TXT = "out.txt";

@Rule

public TemporaryFolder folder = new TemporaryFolder();

@Test

public void inputOutputTryFinally() throws IOException {

final File file = folder.newFile(OUT_TXT);

BufferedOutputStream out = null;

try {

out = new BufferedOutputStream(new FileOutputStream(file));

out.write(HELLO_WORLD.getBytes(UTF_8));

} finally {

if (out != null) {

out.close();

}

}

}

@Test

public void inputOutputCloser() throws IOException {

final File file = folder.newFile(OUT_TXT);

final Closer closer = Closer.create();

try {

final BufferedOutputStream out = closer.register(new BufferedOutputStream(new FileOutputStream(file)));

out.write(HELLO_WORLD.getBytes(UTF_8));

} finally {

closer.close();

}

}

@Test

public void inputOutputTryResources() throws IOException {

final File file = folder.newFile(OUT_TXT);

try (final BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file))) {

out.write(HELLO_WORLD.getBytes(UTF_8));

}

}

}

Here, we’ve used BufferedOutputStream and FileOutputStream to write the classic example of Hello World! Into the file. It’s not advisable to phrase it this way, however:

Out.write(HELLO_WORLD.getBytes() );

In a case like this, the platform default encoding converts the string into bytes, which is fine but can result in problems if there are any changes in the encoding. To convert the string into bytes, the code:

HELLO_WORLD.getBytes(UTF_8)

would come into play, but this isn’t a very elegant solution. A DataOutputStream can improve and streamline this:

@Test

public void dataOutputTryFinally() throws IOException {

final File file = folder.newFile(OUT_TXT);

DataOutputStream out = null;

try {

out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));

out.writeUTF(HELLO_WORLD);

} finally {

if (out != null) {

out.close();

}

}

At this point, the code out.writeUTF(HELLO_WORLD); can be used to write the string directly in UTF-encoded bytes.

BufferedWriter 

​BufferedWriter buffers characters for more streamlined writing of strings, arrays and single characters, as a character-output stream. While the default is large enough for most applications, the buffer size may be specified. In most cases a Writer can send output straight to the byte stream or underlying character. In most cases, a BufferedWriter can be wrapped around any Writer in instances where Write operations can be costly, as in writing to file in Java with OutputStreamWriters or FileWriters.

Here’s an example:

@Test

public void dataOutputTryFinally() throws IOException {

final File file = folder.newFile(OUT_TXT);

DataOutputStream out = null;

try {

out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));

out.writeUTF(HELLO_WORLD);

} finally {

if (out != null) {

out.close();

}

}

This illustrates three different ways to use BufferedWriter. The try…finally pattern comes into play to ensure the writer is closed, even when there’s an exception during the write. bufferedWriterCloser closes the writer with a finally clause, and bufferedWriter TryResources uses “try with resources” syntax that was developed with Java7.

The syntax will differ slightly depending on how you want to close the writer, but the result is still the same regardless. In all these instances, the original file content would be overwritten. Here’s an example of how to handle it if you just want to append the file:

@Test

public void bufferedWriterTryResourcesAppend() throws IOException {

final File file = folder.newFile(OUT_TXT);

try (final Writer writer = new BufferedWriter(new FileWriter(file, true))) {

writer.write(HELLO_WORLD);

}

}

In this example, did you notice the “true” 2nd argument added to FileWriter? It serves the same function as append=true. In the end, the written file will include the string “Hello World!”

PrintWriter 

​Here, we’ll explore a little bit about PrintWriter, which includes some nice features that enhance the standard BufferedWriter:

package com.octoperf;

import com.google.common.io.Closer;

import org.junit.Rule;

import org.junit.Test;

import org.junit.rules.TemporaryFolder;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.io.PrintWriter;

import java.io.Writer;

public class JavaWriteFileTest {

private static final String HELLO_WORLD = "Hello World!";

private static final String OUT_TXT = "out.txt";

@Rule

public TemporaryFolder folder = new TemporaryFolder();

@Test

public void printWriterTryFinally() throws IOException {

final File file = folder.newFile(OUT_TXT);

PrintWriter writer = null;

try {

writer = new PrintWriter(new FileWriter(file));

writer.printf("Hello %s!", "John Smith");

} finally {

if (writer != null) {

writer.close();

}

}

}

@Test

public void printWriterCloser() throws IOException {

final File file = folder.newFile(OUT_TXT);

final Closer closer = Closer.create();

try {

final PrintWriter writer = closer.register(new PrintWriter(new FileWriter(file)));

writer.printf("Hello %s!", "John Smith");

} finally {

closer.close();

}

}

@Test

public void printWriterTryResources() throws IOException {

final File file = folder.newFile(OUT_TXT);

try (PrintWriter writer = new PrintWriter(new FileWriter(file))){

writer.printf("Hello %s!", "John Smith");

}

}

}

Note that we again used three closing methods and still came to the same result. To write a formatted string, writer.printf (“Hello %s!”, “John Smith”); is a convenient approach. This string will include “John Smith” in the file. 

Don’t Forget When You’re Doing a Java Write to File

When reading or writing content from a file, don’t forget to close any associated resources.

Failing to close things properly means a pointer to the file will stay open, causing behaviors such as reaching open file limit or simply being unable to write a file because it’s considered already open.

Best of luck!

Filed Under: Java Tagged With: best ways for java write to file, java, Java write to file, Java write to file methods

Quantitative Aptitude 101: What Does It Mean

September 30, 2018 by Krishna Srinivasan Leave a Comment

Quantitative aptitude is a measure of an individual’s numeric ability and problem-solving skills. This sort of aptitude is highly valued in fields like computer science, engineering, and mathematics because it usually correlates with success in those fields.

However, there is a push to further this understanding in qualitative fields like journalism and the digital arts too. Companies and people are becoming more focused on understanding and improving quantitative aptitude through training and testing in the workplace.

Here’s what you need to know about quantitative aptitude and how to up yours.

Quick Navigation
Here’s a Guide on How to Gauge Your Quantitative Aptitude 
How is Quantitative Aptitude Tested?
Types of Tests to Gauge Quantitative Aptitude
Topics Covered in Quantitative Aptitude Testing
A Further Breakdown of Topics
What Jobs Value Quantitative Aptitude
Reasoning and Reverse Reasoning
Spatial and Abstract Relationships
Modeling
Attention to Detail
How to Further Develop your Quantitative Aptitude
Quantitative Aptitude Grows with Age
Improving Quantitative Aptitude
Tips and Tricks to Solving Questions to Develop Quantitative Aptitude
Read Carefully
Pick at the Details
Do Not Jump to Conclusions
Solve as Many Types of Questions as Possible
Keep Timing your Problem Solving
Improving Your Quantitative Aptitude Can Open New Doors
Computer Science and Data Science Projects
The Future is Interconnected
light bulb

Here’s a Guide on How to Gauge Your Quantitative Aptitude 

How is Quantitative Aptitude Tested?

Gauging quantitative aptitude is a requirement on many important entry tests for different fields. It is also used in the job selection process for many companies including well-known ones like Goldman Sachs.

While quantitative aptitude is traditionally tested using, well, tests. There are other means of gauging that understanding, including through work-related projects like charting the spikes in google searches for a particular product or mapping demand for a service in a particular area.

Types of Tests to Gauge Quantitative Aptitude

There are a number of tests related to measuring quantitative aptitude, including common standardized tests like the SAT, ACT, and GRE.

However, other tests for measuring numeric ability and problem-solving skills are IQ tests, math tests, and application exams. Testing is the most common way of gauging the quantitative aptitude of an individual.

Major companies, especially tech companies, continue to use tests in their interview process to gauge this understanding.

Topics Covered in Quantitative Aptitude Testing

There are many topics covered in quantitative aptitude tests, which also vary by degree depending on how far along you are in understanding use-cases of quantitative aptitude. Some of the larger topic areas of quantitative aptitude testing include arithmetic, algebra, geometry, number systems, and modern mathematics.

Most of the topics are covered in middle school and high school. Developing a strong quantitative aptitude takes time, patience, and hard work to make good progress.

A Further Breakdown of Topics

Some books, like Quantitative Aptitude by R.S. Aggarwal, covering the topic of quantitative aptitude development suggests breaking down the larger topic into arithmetic ability and data interpretation.

The first subtopic, arithmetic ability, includes topics like averages, percentages, roots, and simplifications. The second subtopic, data interpretation, looks at an understanding of tabulation and various graphs like line graphs, bar graphs, and histograms.

What Jobs Value Quantitative Aptitude

While all fields should value a strong aptitude for problem solving and working with numbers, there are a number of fields that require an aptitude for those skills. Some of the most common fields where numeric ability and problem-solving skills are tested include engineering, actuarial science, computer science, economics, statistics, and mathematics.

Not all fields value quantitative aptitude in the same way, but there are commonalities. Those who work in quantitative fields are likely to have developed some of the following skills:

Reasoning and Reverse Reasoning

Logical reasoning is the ability to think through a problem step-by-step using analytics and deductive and inductive methodologies. The ability to think through a problem’s solution backwards is an important skill. It’s powerful in finding and understanding a methodology that works to solve the problem.

Spatial and Abstract Relationships

Knowing how to apply mathematical concepts and apply symbolism to express those concepts is important in communicating results in many heavily quantitative fields. It creates a standardized system to approaching problems among all practitioners within a particular field.

Modeling

The ability to choose from a number of mathematical models to communicate the best solutions to problems in various fields. Field experts, especially those in quantitative fields, need to model problems to communicate the best solutions to clients and to other stakeholders. Modeling also provides a methodology to approaching similar problems in the future.

Attention to Detail

Being accurate is important when working in quantitative fields, since job success depends on correct valuations and calculations. It is important to construct precise formulations and models to communicate solutions in mathematics and in writing.

How to Further Develop your Quantitative Aptitude

Quantitative Aptitude Grows with Age

Research on productivity from the National Institute of Health shows that there are many ways in which changes in age can affect productivity, including on quantitative aptitude. Some of the studies also show a pattern where productivity peaks along with verbal and quantitative reasoning at around 40 years of age.

Improving Quantitative Aptitude

But, just like learning anything else, if you want to further your quantitative aptitude then you’ve got to practice using it.

The trick to improving is to understand that it is not about solving as many problems as possible correctly, but developing an understanding about how to approach many different problems using logic.

The logic and reasoning you develop from solving challenging problems leads to a better aptitude for numeric ability and problem-solving skills.

Tips and Tricks to Solving Questions to Develop Quantitative Aptitude

Some easy tricks to help you build a strong quantitative aptitude involve steps like underlining key bits of information in word problems and deriving formulas that are needed to solve the problem. It is better to grasp the logic given in the problem to find the next step instead of jumping to conclusions about given answers.

Read Carefully

Understanding all the components of a problem-solving question is an important starting point to building quantitative aptitude. Don’t underestimate the value of taking apart a question to understand what needs to be solved for.

Pick at the Details

Underline any details that would prove important pieces of information in solving through the problem. These will start to become relevant as you go through the step-by-step process of problem solving.

Do Not Jump to Conclusions

Grasp the logic of a question first without jumping to a conclusion about how to approach the problem. It is important to identify all the moving parts in a problem before putting pen to paper.

Solve as Many Types of Questions as Possible

Keep attempting many different kinds of problems because this will help build your familiarity in applying the prior three tips and tricks. It will also help you build your familiarity in approaching a wide variety of problem, including word problems, graphic problems, and much more.

Keep Timing your Problem Solving

As you start becoming familiar with a large cache of problem types, start timing your progress in attempting each type of problem.

Recording the time it takes you to solve particular problems will identify skills areas you need to improve on and those that you have already mastered. The point is to decrease your reaction time to many different problems by keeping up your practice.

Man pointing his forehead

Improving Your Quantitative Aptitude Can Open New Doors

While a quantitative aptitude can improve test taking capabilities and measure success for particular jobs, a strong quantitative aptitude also has the potential of strong personal enrichment.

Computer Science and Data Science Projects

Many fields like computer science and data science have general practitioners working on projects in their free time outside of their full-time jobs.

Strengthening quantitative aptitude can lead to exciting project ideas to pursue in those two fields and a better understanding of how to complete such kinds of projects. One platform to look for these kinds of ideas and projects is GitHub.

The Future is Interconnected

The discovery of new fields by combining a focus on strengthening quantitative analysis and numeric ability with other skill areas is a huge boon to the world. It allows us to become more collaborative and innovative in coming up with new ways to improve society and ourselves.

There is also a lot of potential to think up ideas to execute in other fields and work environments. One example is in journalism. Data journalism is a new and upcoming field within the last few years with a lot of potential to change the way we find and tell stories.

Without enthusiasts with strong quantitative aptitudes finding ways to contribute to their own specialized fields there would likely not be discoveries of certain collaborations like data journalism.

Filed Under: Java

Simple Tips to Help You Write a Better Experience Letter

September 25, 2018 by Krishna Srinivasan Leave a Comment

Experience letters offer a history of work that explains the details behind the job and relevant projects done.

The advice in this article will be most relevant to audiences trying to make it into their next job. However, the following steps are also applicable to those trying to show off their work in a letter in a dynamic way.

Quick Navigation
Use These Tips to Help You Write a Better Experience Letter
Know Your Audience
Who are you Talking to?
Focus on the Projects that Matter
Find Common Skills with the Language in the Job Positing
Focus on Tone and Purpose
Narrow in On the Details of Important Projects
Emphasize the Takeaways from Those Important Projects
Punch Up the Writing in Your Experience Letter
Short and Simple is Better Than Long and Boring
Lose Your Audience at Your Own Risk
Leave a Great Lasting Impression 
A Strong Ending
Put a Call to Action in the Last Paragraph
Be Sure to Add Pertinent Contact Information
Use These Tips to Help You Write a Better Experience Letter

Use These Tips to Help You Write a Better Experience Letter

So you’re here to find out how to show off work history in an experience letter that’s eye catching and results-oriented, right? Here are a few easy steps to writing an experience letter that gets you results.

Know Your Audience

The key to a good experience letter includes knowing who you need to address in the letter. Understanding your audience and what they may be looking for is a big step to impressing them, so keep your letter relevant to what the audience needs to hear.

Who are you Talking to?

Most of the time, experience letter writers approach the question of ‘who is my audience?’ as if they’re writing for any future employer. However, understanding how to focus a letter to a specific audience, including those in a specific field, specific department, or even a specific job will make your letter far more effective. Acknowledging your audience as clearly as possible at the beginning of the letter is the best way to ensure a closer reading of the content in your letter.

Focus on the Projects that Matter

There are tips and tricks to finding the best way to communicate your experience in a professional manner while keeping it interesting for your audience. Focusing on the most important details brings out the best information quickly and keeps your readers engaged.

Find Common Skills with the Language in the Job Positing

Put in the extra effort to detail projects that relate to the area of work of whoever reads the letter. It’s important to leave an impression that the work history detailed in the letter proves competency towards accomplishing tasks in a particular area of expertise.

Begin by describing relevant experiences with as many parallels to a future role as possible. If this is for a particular job, then look at the language used in the job posting to find what needs to be addressed in the experience letter.

Focus on Tone and Purpose

Experience letters should be clear and concise. A good way to figure out what sort of tone your audience is expecting in your letter is to identify the way they communicate in public as well as with you.

Are there any circulars or e-mails that give you an idea of your audience’s tone in writing?  This is basically the attitude the audience follows when communicating. Following their style of communicating in your letter makes it more likely that they will take a closer look at the content in your letter.

Narrow in On the Details of Important Projects

One of the strongest points to focus on when approaching this step is detail. Outline the key skill areas that made a project’s development possible and how each of those skills were used in the project.

For example, as a mobile apps developer focused on backend work in Python, detail the work and time put into building an app’s platform and functionality. Explain what was accomplished and how to accomplish it.

Emphasize the Takeaways from Those Important Projects

Whatever the professional background may be, include examples of what impact the letter’s subject had in your department, company, and field. For example, if the subject is a programmer then include challenging problems or bugs that came up during sprint cycles and explanations behind any fixes made to them.

Do not forget to include the impact that the fixes had on the overall project’s success. It goes a long way to show how any work put into fixing specific problems contributed to a team’s overall progress and success during a project too. Teamwork and support are soft skills that are highly valued in IT and other technical fields, especially software engineering roles.

It is also not a bad step to take on the ladder to higher paying management roles if that is something the subject in the letter may be aiming toward.

writing a letter

Punch Up the Writing in Your Experience Letter

Short and Simple is Better Than Long and Boring

Keep the writing short and to the point when describing personal and work histories. Regardless of the details put into the value of the work history, it will always benefit experience letter writers to keep the details pertinent and to a minimum.

Just remember, readers get bored easily, including letter readers. The goal is to grab a reader’s attention fast and keep it for as long as possible.

Be a Better Editor, Learn to Cut

Learning to self-edit by making cuts to a draft is a powerful skill for a writer. This skill applies to experience letter writing too. Try to make it easy for a reader to pick out the best qualities in the letter quickly.

Readers don’t have a lot of patience, so providing a quick breakdown of the value of past work is a luxury your readers will not forget.

Lose Your Audience at Your Own Risk

By continuing to emphasize points or skills that have already been mentioned earlier in the letter will likely kill your chances of making the most of your letter’s space. There is also the added risk of becoming redundant and boring to your audience.

Most readers, including those reading experience letters, skim through the paragraphs instead of taking a closer look and understanding what’s really on the page. Do not take it personally, most readers do not have the time or patience to spare a closer reading.

People have lower attention spans these days and are less inclined to read, so make sure the letter’s message is clear. All the points, from the first point to the last point, should be clear and detailed while describing your work history. The first time a point is emphasized should likely be the last time it is emphasized in the letter.

Leave a Great Lasting Impression 

A Strong Ending

End on a strong note in the experience letter. If details need to be revisited, then this is the place to repeat them. However, do not repeat anything verbatim.

The readers need to continue to learn about the strength of a work history in an experience letter, so add something original to any earlier mentioned details. This keeps the content moving forward while driving the reader’s attention back to important points and other components in the letter.

Put a Call to Action in the Last Paragraph

The last paragraph is usually a call to action about why the letter is important in the first place. Let the letter’s recipient know that they should take action, like hiring the subject in the letter.

More often than not, an experience letter will have a sentence to inform a reader that a candidate’s work history is a good fit for a role in the field or for a particular job. Circle back in this paragraph to emphasize the strongest points in the letter and why those pointers reveal a candidate to be qualified for a role in the field.

Be Sure to Add Pertinent Contact Information

Be Sure to Add Pertinent Contact Information

Your audience needs a way to get a hold of you. It’s important to remember to add some contact information, so your audiences have the best means of reaching you for follow up questions.

Openness and honesty go a long way in establishing good faith between two parties. This is no exception while shopping around for a new job with an experience letter in hand.

Adding in a best way to reach the writer in the last paragraph of the experience letter provides a sense of accountability and trust in your content. This puts audiences reading the letter at ease about the veracity of the information because they now have a way of going straight to the source.

Filed Under: Java

Coalesce In SQL: Guide With Useful Tips, Examples And More

August 27, 2018 by Krishna Srinivasan Leave a Comment

Even though people sometimes think of Structured Query Language (SQL) as a database system, that's not strictly correct.

Instead, SQL is used to manage information within databases, which makes it a relational database management system (RDBMS).

Given that, it's primary purpose is to extract information from databases based on user-submitted queries using predefined functions.

Anyone who has worked with SQL is likely familiar with its basic commands such as SELECT, AND OR, WHERE, and HAVING. When it comes to the concept of defining NULL conditions, however, most programmers will be more familiar with the ISNULL function as opposed to COALESCE.

Although it's underutilized, COALESCE is a powerful, advanced logic function with capabilities extending beyond related NULL commands. When and how should you use COALESCE in SQL? We'll go over the basics below to get you started.

Quick Navigation
The COALESCE Function
COALESCE & CASE 
The ISNULL Function
SQL Server ISNULL
MySQL ISNULL
COALESCE vs. ISNULL
Additional COALESCE Resources
Microsoft
MSSQLTips.com
TeamSQL
Tutorial Gateway
Stack Overflow
Using COALESCE

The COALESCE Function

Using COALESCE in either SQL Server or MySQL allows you to search an object – that is, a table – in a relational database until you find the first non-NULL value. It's often seen as being much like the ISNULL function, so we'll talk about the distinctions between the two a little later below.

To use COALESCE, you would write:

COALESCE ("expression 1", "expression 2", ...)

To see this in action, let's say we have the following contact information in a table called Email_Info:

Name​

Business_email

School_email

Personal_email​​​​

Justin

justin@bab.com

justin@tstc.edu

justin65@gmail.com

Keith

NULL

keith@baylor.edu

keith1@yahoo.com

Andy

NULL

NULL

andy@aol.com

Now, let's perform a search to find the preferred email address to use for contacting these people as per the following three rules:

  • 1
    If there is a business email address, use it.
  • 2
    If there is not a business email address, use the school email address.
  • 3
    If there is not a business or school email address but there is a personal email address, use it.

Then, we can use COALESCE to perform a search with these parameters in the Email_Info table:

SELECT Name, COALESCE (Business_email, School_email, Personal_email) Contact_Email FROM Email_Info;

Finally, we'd have these results as the query output:

Name

Contact_Email

Justin

justin@bab.com

Keith

keith@baylor.edu

Andy

andy@aol.com

COALESCE & CASE 

As you may have noticed by now, COALESCE is very similar to the CASE function, which uses if-then-else logic to evaluate data and subsequently return a value when the first in a series of conditions is met. There's a good reason for that: COALESCE is actually a shortcut for the CASE function. Let's take another look at the COALESCE function syntax:

COALESCE ("expression 1", "expression 2", ...)

Using CASE to perform the same search would look like this:

CASE

WHEN (expression1 IS NOT NULL) THEN expression1

WHEN (expression2 IS NOT NULL) THEN expression2

...

ELSE expression

END​

So, if you've been using CASE to perform these types of database queries, COALESCE will allow you to do the same action with less code.


The ISNULL Function

To understand how COALESCE is distinct from the ISNULL function it's commonly compared to, we need to take a quick look at how ISNULL operates. That depends, however, on if you're using SQL Server or MySQL, both of which are RDMBSs.

SQL Server ISNULL

In SQL Server, ISNULL is used to replace a NULL value with another value. For example, I might have the following table called Class_Data:

Class_Number

Students

1301-1

27

1301-2

30

1301-3

NULL

To calculate the total number of students as well as replace the NULL value with a number of my choice, I'd write the following in SQL:

SELECT SUM (ISNULL(Students,25)) FROM Class_Data;

Then, I'd receive the following result by adding 27 + 30 + 25 (the number replacing the NULL value):

SUM (ISNULL(Students,25))

82

MySQL ISNULL

In MySQL, however, ISNULL is used to determine if an expression is NULL or not. For example, I could write the following two queries:

ISNULL(4*4)

ISNULL(4*0)

With the first expression, 4 x 4 is 16 – not a NULL value – so the result would be:

ISNULL(4*4) returns 0

With the second expression, 4 x 0 is 0 – a NULL value – so the result would be:

ISNULL(4*0) returns 1

COALESCE vs. ISNULL

While both COALESCE and ISNULL return values based on NULL vs. non-NULL query results, there are some important distinctions between the two:

  • 1
    COALESCE is an American National Standards Institute (ANSI) standard, but ISNULL is not.
  • 2
    ISNULL will evaluate data only once, while COALESCE will do this multiple times.
  • 3
    ISNULL can only use two parameters, but COALESCE can use a variable number.
  • 4
    The first parameter's data type will be used by ISNULL. COALESCE follows CASE rules which return the highest precedence data type value.
  • 5
    Validations are performed differently. An ISNULL which is NULL is converted to an integer (int). A data type must be provided when using COALESCE.
  • 6
    Result expression NULLability is also different. An ISNULL return value is always considered NOT NULLable. Non-NULL parameters when using COALESCE will be considered NULL.

Additional COALESCE Resources

Now that we've gone over the basics of using COALESCE, how it relates to CASE, and how it's different from ISNULL, you probably want to learn even more about how to use it. The websites below offer detailed articles and tutorials, extensive examples of code, and handy tips for its use.

Microsoft

SQL Server and MySQL are Microsoft products, so a good place to start is with the COALESCE documentation at the company's website. In addition to a detailed overview of COALESCE, there are four examples of code – two simple and two complex – which illustrate the function's use:

  • 1
    Simple: Using the AdventureWorks2012 database, a search is performed to return the first non-NULL value in a column.
  • 2
    Complex: After creating a table with three columns for hourly wage, salary, and commission, a search is performed to find total salaries paid.
  • 3
    Simple: After performing a search of a table with clothing product information, there's a discussion explaining why the result set includes unexpected information due to a lack of defined parameters.
  • 4
    Complex: The salary table from example 2 above is queried again, this time for only non-NULL values in its columns.

MSSQLTips.com

MSSQLTips.com has two useful articles: The Many Uses of COALESCE in SQL Server and Deciding between COALESCE and ISNULL in SQL Server. Each one begins with an explicit problem statement and the rest of the article provides a detailed discussion and solution.

The first one provides a basic overview of COALESCE. After that, there's a discussion with examples demonstrating how this function can be used to pivot data from the AdventureWorks2012 database.

Then, you'll learn about using COALESCE with multiple arguments as well as perform multiple SQL statements. You should also look at the extensive reader comments at the end of the article which cover pertinent topics and troubleshooting issues.

The second article begins with a brief discussion including examples of code showing how the COALESCE and ISNULL functions use data precedence differently. Then, additional extended examples of these functions in action demonstrate the key differences in performance. Again, you should check out the comments at the end which offer useful information.

Plus, think ISNULL always runs faster than COALESCE on SQL Server? There are some revealing results from four different, simple tests using two variables which were performed 500,000 times to compare run times:

  • 1
    Both NULL arguments
  • 2
    First argument NULL
  • 3
    Second argument NULL
  • 4
    Neither argument NULL

COALESCE was faster in the first two tests, the third one was a tie, and ISNULL was quicker in the final one.

TeamSQL

This article begins with a description of the COALESCE function. After that, there are two detailed examples demonstrating different scenarios where it's useful: determining customer charges at an Internet service provider and dealing with a customer's unnamed service as a query result.

One excellent feature is the inclusion of screenshots of both the tables and code being used as opposed to just having that information on the webpage itself.

Tutorial Gateway

To learn some additional features of the COALESCE function, you should check out this tutorial which also uses screenshots to show input and output.

First, there's an example using string data. Then, the second example uses numerical data. Finally, there is a practical example which queries an employee contact information database – much like the example about sorting email addresses above – but with many more data fields included.

Stack Overflow

Not only do COALESCE and ISNULL handle data precedence differently, COALESCE's data precedence can also change when running on MySQL versus SQL Server even though it is an ANSI standard.

If you're generating error messages about converting varchar values to integers, this is well worth looking at.


Using COALESCE

Even experienced SQL Server and MySQL programmers may not be that familiar with the COALESCE function and the capabilities it offers.

The end goal of coding, however, is always the same: write the most powerful programs possible with the least amount of code.

To that end, you should use COALESCE whenever possible to perform the types of searches and queries detailed above.

Filed Under: Java

How To Use The JList Function In Java Beginner’s Tutorial

August 21, 2018 by Krishna Srinivasan Leave a Comment

Let's say you're creating an address form on a webpage which asks for the state a user lives in. Do you really want to list all 50 states on the form for someone to choose from? After all, that information will take up too much valuable space on the page and create unnecessary clutter.

What should you do?

The simplest solution is to use Java's JList function to create a pop-up menu with a list of states for a user to choose from. The selection is made, the options box disappears, and life moves on.

Then again, to do this, you'll need to understand the ins and outs of using JList. To give you a hand, we'll go over the basics of what you'll need to know below.

Quick Navigation
What is JList?
JList Constructors & Methods
JList Constructors
JList Methods
Using JList
1. Building a List Model
2. Initializing a List
3. Rendering List Cells
4. Selecting List Items
5. Adding & Removing List Items
Additional JList Features
Split Panes
Box Layout
List Data Listener
Custom Models
Sample JList
Additional JList Resources

What is JList?

JList is a tool in Java which allows you to build a graphical user interface (GUI) to display a list of items and allow a user to select one or more of these items. It's a Swing component, part of a larger toolkit to build application programming interfaces (APIs). A separate component, ListModel, contains the data for the list being displayed.

JList

The "J" at the beginning of JList indicates it's a descendant of the JComponent class as are all the tools which utilize Swing architecture. This includes the following features:

  • Tool tips: Text boxes which pop up when a cursor hovers over a page element.
  • Accessibility:  Accessibility interface methods are included.
  • Painting infrastructure: Support for borders and double buffering of visual elements.
  • Component-specific properties: Any JComponent descendant object can be associated with name-object pairs.
  • Pluggable look and feel (L&F): Interface design can be determined by the programmer or, if desired, chosen by the user when initiated.
  • Keystroke handling: Define keyboard events to initiate actions automatically.

JList Constructors & Methods

The API for using JList constructors and methods breaks out into four areas:

  • Initializing list data
  • Managing list data
  • Displaying the list
  • Managing list selection

JList Constructors

These are the most common JList constructors:

  • JList(): Creates a read-only, empty model.
  • JList(E[] listData): Displays the elements in a specified array.
  • JList(ListModel<E> dataModel): Displays the elements from a specified, non-null model.
  • JList(Vector<? extends E> listData): Displays the elements from a specified Vector.

JList Methods

Common methods used with JList constructors include:

  • getModel(): Returns the data model holding list items to be displayed.
  • getSelectedIndex(): Returns the smallest selected cell index.
  • setListData(E[] listData): Builds a read-only ListModel.
  • setListData(Vector<? extends E> listData): Builds a read-only ListModel from a Vector.
  • addListSelectionListener(ListSelectionListener listener): Each time a selection is changed, the specified listener is notified.

Using JList

Depending on the relative size, complexity, and visual properties of the list you want to display, JList's options are both varied and robust. There are, however, five basic steps you'll need to work through each time you use the JList function:

  • Building a list model
  • Initializing a list
  • Rendering list cells
  • Selecting list items
  • Adding and removing list items

1. Building a List Model

Before you can build the JList GUI, you need to create a model for your list's data. There are three options to do this:

  • 1
    ListModel: You manage all elements of the list.
  • 2
    AbstractListModel: You manage the list data.
  • 3
    DefaultListModel: Most list elements managed by default parameters.

2. Initializing a List

Once you've chosen your model, you'll need to use code from ListDialog.java to initialize the list and populate its array with items from a previously defined object. Or, as per the constructors listed above, you can create a list from an object or Vector as per the ListModel component.

This is also when you can determine display characteristics such as adding a scroll pane or how the text will be displayed: vertical, vertical with text wrapping, or horizontal with text wrapping.

3. Rendering List Cells

List items are displayed by using a cell renderer object to format icons and strings by via toString. If you want to customize this display, you'll need to utilize the ListCellRenderer interface. This will create a "stamp" to paint components within a JList cell such as the foreground or background colors.

4. Selecting List Items

The ListSelectionModel component manages the list selection options. By default, this includes the ability to choose any number of items as per the three following modes:

  • SINGLE_SELECTION: Only one item can be selected. If a second item is selected, the previous item is deselected.
  • SINGLE_INTERVAL_SELECTION: Multiple items in a contiguous range can be selected. If a new range is selected, the previous items are deselected.
  • MULTIPLE_INTERVAL_SELECTION: This is the default mode which allows any combination or number of items to be chosen.
JList Methods

5. Adding & Removing List Items

Lists can be either mutable (changeable) or immutable (unchanging). In the case of listing all 50 US states, you'd likely want that list to be immutable. On the other hand, you'll need to set up a mutable list if you're going to be adding or removing items from it such as, for example, different products or payment options over time.

There are two basic ways to do this:

  • insertElementAt: Insert the new item after the current selection or at the beginning of the list if there is no existing selection.
  • DefaultListModel addElement: Insert the new item at the end of the list.

Additional JList Features

Of course, depending on the complexity of the list you want users to access, there are a variety of additional features which can be incorporated once you master the basics:

  • Split panes
  • Box layout
  • List data listener
  • Custom models

Split Panes

JSplitPane allows you to display two separate components either one on top of the other or side by side. For example, in a side-by-side display, you could list product names in the left pane, and when a selection is made by the user, a picture of the product appears in the right-hand pane.

To try this out, open Java Web Start (JDK 7 or later), and select the Launch button for the SplitPaneDemo. Or, you can use this example provided by Oracle to compile and run your own split-pane list.

Box Layout

JList's BoxLayout allows you to put all selections in a single box either in rows or stacked on top of each other. This is similar to FlowLayout but offers more powerful options such as moving and rearranging elements within the box in relationship to each other.

Be aware: Even Oracle admits coding box layouts by hand can be tricky and suggests you consider using the GroupLayout manager with a builder tool such as NetBeans IDE.

List Data Listener

When the contents of a list change, that's a data event. By default, list models are immutable, so to use a data listener – or even have a need for one – you'll need to make sure you've created a mutable list. An example of an action requiring a list data listener would be offering users the ability to add items to an online wish list.

Custom Models

By default, almost all Swing components work from models. For example, an onscreen button uses a model file to store its image, what keyboard action it's associated with, and other properties. Plus, components can use multiple models. For example, a list uses one model to track the existing selection a user has made while another one is used for list data.

So, if you wanted to allow users to enter data which is then further manipulated for them, you'd need to create a custom model. For example, perhaps you have a temperature converter. Users could enter degrees in Fahrenheit and the model you've created would convert that into a Celsius measurement. Or, you could allow users to convert pounds to kilograms, miles to kilometers, and so on.

codes

Sample JList

Now that we've covered some of the theory, here's the code for a basic JList GUI which displays a list of four car manufacturers:

import javax.swing.*;

public class ListDemo

{

     ListDemo(){

          JFrame f= new JFrame();

          DefaultListModel<String> l1 = new DefaultListModel<>();

          l1.addElement("Audi");

          l1.addElement("Chevrolet");

          l1.addElement("Ford");

          l1.addElement("Mercedes");

          JList<String> list = new JList<>(l1);

          list.setBounds(150,150, 100,100);

          f.add(list);

          f.setSize(500,500);

          f.setLayout(null);

          f.setVisible(true);

     }

     public static void main(String args[])

     {

          new ListDemo();

     }

}

Remember, as you add more bells and whistles to your list's GUI, the code will be longer and more complex.

Additional JList Resources

Thanks to Java being open source, there are many resources available for programmers beginning with Oracle's complete Java Platform, Standard Edition 8 API Specification documentation. All that information makes for some dense reading, however, so for JList tips, in particular, you might also take a look at the tutorials at these websites:

  • C​​​​​odeJava
  • GeeksforGeeks
  • Tutorials Point

When you're programming with Java, you want to make sure you're using all its features to maximum effect. Once you're familiar with JList's constructors and methods, you will be well on your way to creating dynamic lists with a variety of functions for users.

Filed Under: Java

Guide On How To Master Encapsulation In Java For Beginners

July 26, 2018 by Krishna Srinivasan Leave a Comment

Encapsulation is the process by which data is combined into a single unit and can't be accessed by unauthorized code or users. Think of encapsulation as being like a sack of chips at the grocery store. You can look at the sack of chips, but until you pay for it, you're not authorized to open it to eat the individual chips inside.

Protecting computer data is an ongoing issue. After all, there's some information you must be willing to share such as your medical records at a doctor's office. You never want this information, of course, to be hacked by outside entities. Even within a company or organization, though, you also want the fewest number of people – only those who need to know – to have access to this data.

So, what exactly is data encapsulation in Java? How does it work, and when should you use it? We'll go over the basics below so you can protect your data as well as possible.

Quick Navigation
What is Data Encapsulation in Java?
Using Data Encapsulation in Java
Checking Data Encapsulation
3 Common Data Encapsulation Errors
Variable is Less Restricted than in the Getter & Setter
Getter Contains Returned Object Reference
Setter Contains Assigned Object Reference
Data Encapsulation Resources

What is Data Encapsulation in Java?

java logo

Data encapsulation is an object-oriented programming (OOP) concept designed to protect data. This is done by combining the variables (data) and code (methods) into one package. After encapsulation, all variables will be inaccessible unless using methods associated with that class. This process is also known as data hiding.

Performing data encapsulation is a three-step process:

  1. Set class variables as private.
  2. Define the getter method which retrieves variable data to be read.
  3. Define the setter method which allows data to be changed or not.

There are a variety of benefits achieved through encapsulation:

 

  • Flexibility: Class variables can be easily set to read-only or write-only. Plus, you can limit the types of data which can be entered in a field. You can also trigger events when data is modified.
  • Data hiding: Users will not be able to access variable data unless using the predefined getter method.

 

  • Maintain data: Encapsulated application code is segmented into discrete units – setters, getters, methods, classes, and so on – which means you can work with a single unit without affecting the performance of others.

 

  • Reuse data: Encapsulated data can be reused at multiple points in the application programming interface (API) or even across multiple APIs.

Using Data Encapsulation in Java

As noted above, data encapsulation is a three-step process. First, you'll set class variables as private. Second, you'll define the getter methods to access this variable data. Finally, defined setter methods will determine if this data can be changed.

For example, let's look at this sample data encapsulation code below:

public class SampleEncap {

private String idNumber;

private String name;

private int age;

 

public String getIdNumber() {

return idNumber;

}

 

public String getName() {

return name;

}

 

public int getAge() {

return age;

}

 

public void setIdNumber(String newIdNumber) {

idNumber = newIdNumber;

}

 

public void setName(String newName) {

name = newName;

}

 

public void setIdAge(int newAge) {

newAge = newAge;

}

}

As you'll see by looking at the code above, it has three sections:

  • variable data idNum, Name, and age are set to private
  • getter rules allow the data to be viewed
  • setter rules make this read-only data

Checking Data Encapsulation

Once you've set up your data encapsulation methods, you need to check the code to make sure it's executing correctly. First, input variable data to be checked, and then, generate output as per this sample code:

public class TestSampleEncap

{

public static void main (String[] args)

{

 

obj.setIdNumber(0419);

obj.setName("Justin");

obj.setAge(34);

 

System.out.println("Customer ID Number: " + obj.getIdNumber());

System.out.println("Customer Name: " + obj.getName());

System.out.println("Customer Age: " + obj.getAge());

}

}

As you can see, there are two basic components to this code: Inputting the customer information to be checked via the system output upon completing execution. In this case, we should have the following output results:

Customer ID Number: 0419

Customer Name: Justin

Customer Age: 34

3 Common Data Encapsulation Errors

While defining and using getters and setters is relatively straightforward, keep an eye out for these three common errors. Each of them demonstrates how even the smallest coding problem can keep your data from being hidden as intended.

Variable is Less Restricted than in the Getter & Setter

Look closely at what's happening here:

public String idNumber;

 

public void setIdNumber(String id) {

this.idNumber = id;

}

 

public String getIdNumber() {

return this.idNumber.

}

While the setter and getter are set up correctly, that's a moot point because the intial idNumber string has been defined as public in the first line. Variable data can now be accessed directly by using the dot (.) operator. To avoid this problem, the first line of code should be rewritten to incorporate a restricted access modifier:

private String idNumber;

Getter Contains Returned Object Reference

Now, let's examine this getter to display a student's grades in a class:

private int[] grades;

public int[] getGrades() {

return this.grades;

}

Then, we use this code to create an array with the grades in it:

int[] myGrades = {80, 50, 70, 90, 85};

setGrades(myGrades);

displayGrades();

int[] copyGrades = getGrades();

copyGrades[1] = 1;

displayGrades();

The issue is the following mismatched results will be generated:

80 50 70 90 85

80 1 70 90 85

The problem is at line 5 of the getter code because this method as defined returns the reference of the internal variable grades directly. The effect is outside code can also access this reference and make changes to the object.

Don't directly return the reference in the getter. Instead, return an object copy. That way, outside code can only ever access a copy, not the actual internal object itself. So, rewrite the getter like this:

public int[] getGrades() {

int[] copy = new int[this.grades.length];

System.arraycopy(this.grades, 0, copy, 0, copy.length);

return copy;

}

Our data is now actually encapsulated and inaccessible to unauthorized code.

Setter Contains Assigned Object Reference

Here's another problem worth discussing. First, look at this setter code for a gradebook:

private int[] grades;

public void setGrades(int[] grd) {

this.grades = grd;

}

So far, so good, right? This code below, however, will demonstrate the issue we ultimately encounter:

int[] myGrades = {80, 50, 70, 90, 85};

setGrades(myGrades);

displayGrades();

myGrades[1] = 1;

displayGrades();

The problem finally shows up with this code to display the grades:

public void displayGrades() {

for (int i = 0; i < this.grades.length; i++) {

System.out.print(this.grades[i] + " ");

}

System.out.println();

}

Right now, the values produced by lines 2 and 3 above will be the same:

80 50 70 90 85

There's a problem, though, with line 4 if we rewrite it like this, which changes the second element in the array:

myGrades[1] = 1;

Now, if we execute the display Grades code again, look at what happens to the second number in the array:

80 1 70 90 85

The grade has changed from a 50 to a 1. Sure, this seems a bit convoluted to be much of an issue, but the problem is data has been manipulated outside of the setter's parameters which we defined earlier. Once again, let's look at the method to set Grades:

public void setGrades(int[] grd) {

this.grades = grd;

}

Here's the problem: The grades variable is directly assigned to the method’s parameter variable grid. The result is both variables refer to the same object: the myGrades array. Any changes made to these grades variables or the myGrades variable will affect the same object.

The solution is to copy elements one by one from the grd array to the grades array. Your updated setter code should look like this:

public void setGrades(int[] grd) {

this.grades = new int[grd.length];

System.arraycopy(grd, 0, this.grades, 0, grd.length);

}

The resulting output from lines 2 and 3 of the display code will now be consistent as myGrades[1] = 1; no longer affects the array grades:

80 50 70 90 85

80 50 70 90 85

Remember: When passing an object reference into a setter, don’t subsequently copy the reference into the internal variable. Instead, copy elements from one array to another by utilizing the method System.arraycopy().

Data Encapsulation Resources

The first place to learn more about data encapsulation in Java is at Oracle's Java Development Kit (JDK) knowledge base. You can access a variety of different resources – API documentation, videos, and downloadable books – for each JDK release version.

In addition, you should check out Encapsulation in Java OOPs. This extensive tutorial uses video and screenshots to discuss how encapsulation and data hiding work in Java. Plus, there's an interesting section on how data hiding can, for example, protect bank accounts from hackers.

While the ins and outs of data encapsulation and its getters and setters can be a bit overwhelming at first, it's critical you effectively incorporate these methods into your Java programming. After all, it's not just that you need to protect data from being accessed or manipulated by outside hackers. You must also restrict access to only those people who need to work with it. 

Filed Under: Java

A Beginner’s Guide And Understanding To Type Casting In Java

July 21, 2018 by Krishna Srinivasan Leave a Comment

We convert data from one type to another all the time. If you visit Europe and drive a car, for example, you'll likely convert kilometers per hour to miles per hour in your head to have a better sense of how fast you're going. You'll also be using conversion when you withdraw euros instead of dollars from an ATM there.

The same idea applies to the Java programming language. All data is categorized by type so programs know how to handle it when executing. Depending on what you want a program to do, however, on occasion you'll need to change the category of the data you're using. This doesn't change the data itself – after all, a car travels at an equivalent rate of speed whether it's measured in kilometers or miles per hour – but only how it's being referenced.

What are the data types in Java? How do you change data types? We'll go over all this and more below as we cover what you need to know about type casting in Java.

Quick Navigation
Java Data Types
Upcasting in Java
Downcasting in Java
Cast() Method
Additional Type Casting in Java Resources

Java Data Types

java data types

There are three basic categories of data in Java:

  • True/false
  • Text characters
  • Numbers

This table breaks out the specific types of data within these categories.

Category    Data Type    Contains        Size

T/F        boolean    true or false        1 bit

Text        char        Unicode text character    16 bits

Number    byte        signed integer        8 bits

Number    short        signed integer        16 bits

Number    int        signed integer        32 bits

Number    long        signed integer        64 bits

Number    float        IEEE 754 floating point    32 bits

Number    double        IEEE 754 floating point    64 bits

Any number can be moved from a smaller to larger number size such as an 8-bit byte to a 16-bit short (or more!) with no problem as you're still working with data in the number category. You don't even have to do anything as Java will implicitly perform this conversion.

On the other hand, even though it's moving from a smaller to a larger size, 1-bit boolean data cannot automatically be converted to 16-bit Unicode because these are two different data types. If a program attempts this, an automatic error message will be generated. To avoid this problem, you'll need to explicitly convert these data types within the program you're writing.

Upcasting in Java

The example above recasting a number's data type from a byte to short – that is, from a subclass to a superclass – is also called upcasting. Let's look at how this works by defining a class called Trucks:

public class Trucks {

public void fuel() {

// ...

}

}

After this, we can extend the Trucks class by adding Chevrolet:

public class Chevrolet extends Trucks {

public void fuel() {

// ...

}

public void diesel() {

// ...

}

}

Let's create a Chevrolet class object and assign it the reference variable type Chevrolet:

Chevrolet chevrolet = new Chevrolet();

And we can also assign it to the reference variable of type Trucks:

Trucks trucks = Chevrolet;

With the code above, we do not need to explicitly change the data types because implicit upcasting will occur. If we did explicitly want to do this, here's the code:

Trucks = (trucks) Chevrolet;

Keep in mind: At this point we can’t invoke diesel() on the variable Trucks because we'd receive the following compiler error message:

// trucks.diesel(); The method diesel() is undefined for the type Trucks

We'd need to downcast trucks to invoke diesel, and we'll cover that below. Regarding upcasting, however, now we can utilize polymorphism.

Polymorphism

Polymorphism is when you have different members making up a larger overall group. For example, pennies, dimes, and quarters are different members of the overall group known as currency. In the case of our trucks example, thanks to polytheism, we can add yet another subclass to Trucks called Ford:

public class For extends Trucks {

public void fuel() {

        // ...

   }

}

After this, let's define the fuel() method to categorize Chevrolets and Fords as trucks:

public class TruckGas {

public void feed(List<Truck> trucks) {

trucks.forEach(truck -> {

truck.fuel();

});

}

}

TruckGas isn't concerned with either Chevrolets or Fords in particular as trucks – and all the objects associated with it – will now be in the fuel() method.

When we add specific types of objects to the truck list, upcasting implicitly takes place:

List<Trucks> trucks = new ArrayList<>();

trucks.add(new Chevrolet());

trucks.add(new Ford());

new TruckGas().fuel(trucks)

Thanks to polymorphism, every Chevrolet and Ford is a truck.

Overriding

In the code above, the fuel() method has been overridden. While fuel() is called on the variable of the Trucks type, the work is performed by methods invoked on the actual objects Chevrolets and Fords:

public void feed(List<Truck> trucks) {

trucks.forEach(truck -> {

truck.fuel();

});

}

We can see what the methods for both Chevrolets and Fords are called if we add logging:

web - 2018-07-23 08:43:37,354 [main] INFO com.javabeat.casting.Chevrolet - chevrolet is fueling

web - 2018-07-23 08:43:37,363 [main] INFO com.javabeat.casting.Ford - ford is fueling

Downcasting in Java

Unlike upcasting where a subclass is cast as a superclass, downcasting is the opposite action: casting a superclass as a subclass. And, while a compiler will implicitly upcast, we'll have to write code to explicitly downcast. Let’s take a look at this example:

Truck truck = new Chevrolet();

The truck variable refers to the instance of Chevrolet. So, let’s say we need to invoke Chevrolet's diesel() method on truck. The compiler, however, will generate an error message saying the diesel() method doesn’t exist for the type Truck. This means we must downcast truck to Chevrolet to call diesel:

((Chevrolet) truck).diesel();

Now, we'll rewrite the earlier TruckGas example with the diesel() method:

public class TruckGas {

public void feed(List<Truck> trucks) {

trucks.forEach(truck -> {

truck.fuel();

if (truck instanceof Chevrolet) {

((Chevrolet) truck).diesel();

}

});

}

}

At this point, we're able to gain access to all methods available to the Chevrolet class. We can check the log to make sure diesel() is actually called:

web - 2018-07-23 10:12:33,445 [main] INFO com.javabeat.casting.Chevrolet - chevrolet is fueling

web - 2018-07-23 10:12:33,454 [main] INFO com.javabeat.casting.Chevrolet - diesel

web - 2018-07-23 10:12:33,455 [main] INFO com.javabeat.casting.Ford - ford is fueling

instanceof Operator

You'll note in the example above we only downcast objects which are instances of Chevrolet. That's why we used the operator instanceof to do this:

if (truck instanceof Chevrolet) {

((Chevrolet) truck).diesel();

}

Cast() Method

Finally, we can also use the Class methods to cast object types:

public void whenDowncastToChevroletWithCastMethod_thenDieselIsCalled() {

Truck truck = new Chevrolet();

if (Truck.class.isInstance(truck)) {

Chevrolet chevrolet = Chevreolet.class.cast(truck);

chevrolet.diesel();

}

}

In the code above, as opposed to using cast and instanceof operators, cast() and isInstance() methods are utilized. This is most commonly done when using generic types.

Additional Type Casting in Java Resources

While we've gone over the basics of type casting in Java, there are more ins and outs to all this you'll want to be familiar with. One benefit of Java being open source is that there are plenty of reference sites and tutorials available. Given that, you should check out these free Java-related resources.

Oracle

The first place to begin is with the Java documentation available at the Oracle website. In particular, you'll want to take a look at Chapter 5: Conversions and Contexts. This information dives even deeper into the specific conventions and uses of casting and identity conversion:

  • widening and narrowing primitive conversions
  • widening and narrowing reference conversions
  • boxing conversion
  • unboxing conversion
  • unchecked conversion
  • capture conversion
  • string conversion
  • value set conversion
  • forbidden conversions

Plus, you'll learn about the various contexts where all these conversions operate: assignment, invocation, string, casting, and numeric.

Wideskills

In this detailed Java Object Typecasting tutorial, you'll walk through both upcasting and downcasting via detailed screenshots and examples of code. Plus, the ClassCastException error message and how to avoid it are discussed at length. You also have the option to download all the source code used as examples.

There is a wide range of other coding-related tutorials at the Wideskills site beyond the twenty covering Java. Additional subject areas include Microsoft programming, mobile device programing, databases, and more.

fresh2refresh

A wide variety of topics are covered in this in-depth Java – Type Conversion and Casting tutorial: primitive and reference data types, arithmetic promotion, assignment conversion, and method invocation conversion. In addition, you can access an online Java compiler as well as other compilers such as C, C++, C#, Python, and Ruby.

You might also look at the other subject areas with tutorials: SQL, Unix, XML, C++, C, and JSP. The XML tutorial series, for example, covers twelve different topics such as document type definitions (DTDs), entities, and XLinks and XPointers.

Both upcasting and downcasting are powerful operations within Java you'll need to thoroughly understand to avoid compiler error messages. Remember: While upcasting is done automatically – that is, implicitly – by the compiler, you'll need to write code to explicitly downcast data types and generate the correct output.

Filed Under: Java

IndiaBIX Review: What You Need To Know

June 15, 2018 by Krishna Srinivasan Leave a Comment

Online aptitude and career placement resources like IndiaBIX are rapidly becoming a critical tool for graduating students preparing to enter the job market.

The job market is competitive, and graduates are under pressure to bring additional skills, education and experience if they want the best jobs with the most highly respected companies.

Companies need to find the right employee before they invest in a new hire. They want to know employees have put in the time to acquire the right mix of skills and expertise.

Schools also know how competitive and cut throat the job market can be. Even as they’re feeling pressure to graduate only the best and brightest students, they can only do so much. Preparing every student for every possible placement question or interview situation is impossible.

Aptitude tests, competitive exams, entrance tests, and online examinations are difficult, but the career placement tests for the best companies and multinational corporations (MNCs) are even more difficult. Students that hope to succeed in the modern job market need an edge. They need preparation beyond schooling and classes. That’s where online resources such as IndiaBIX, a crowdsourced online tool for career placement, can help.

Companies are constantly adjusting their mix of questions for career placement tests. Company success depends on finding the right new hires. Online career placement resources like IndiaBIX can help even the odds for prospective employees by supplementing schooling with resources focused on career placement. They offer an edge before the interview and testing even begins.

We’ll take a close look at IndiaBIX. We’ll review what makes the site unique and see how it stacks up to other online resources for campus placement tests.  

Quick Navigation
What Makes IndiaBIX Unique?
1. General Aptitude on IndiaBIX
2. Verbal and Reasoning on IndiaBIX
3. Current Affairs and General Knowledge for IndiaBIX
4. Online Tests for IndiaBIX
5. Interview Questions and Answers for IndiaBIX
6. Puzzles for IndiaBIX
7. Engineering for IndiaBIX
8. Programming for IndiaBIX
9. Technical Multiple-Choice Questions (MCQs) for IndiaBIX
10. Technical Short Answers for IndiaBIX
11. Medical/Science for IndiaBIX
12. Discussion Forum for IndiaBIX
Pricing for A2 Hosting
Public Perception of A2 Hosting
How IndiaBIX Compares to the Market
What We Think of IndiaBIX

What Makes IndiaBIX Unique?


IndiaBIX Website

Websites like IndiaBIX are built and designed to help students with career and campus placement exams and screening. As a crowdsourced site, IndiaBIX grows and develops as students interact on the site.

Let’s take a close look at what IndiaBIX has to offer.

1. General Aptitude on IndiaBIX

General Aptitude consists of four different sections – Arithmetic Aptitude, Data Interpretation, an Online Aptitude and a Data Interpretation Test. Clicking on any section will take you deeper into the content. For example, clicking on Arithmetic Aptitude will take you to a list of topics like Profit and Loss, Average, Stocks and Shares, or Decimal Fraction. Click on a topic and you’ll find sample questions. You can do the work and then view the answer, or even discuss the questions and answers in a forum. Clicking on a test section will take you to sample tests with questions and a time limit, letting you review your ability in the section.

2. Verbal and Reasoning on IndiaBIX

Verbal and Reasoning also consists of four sections – Verbal Ability, Logical Reasoning, Verbal Reasoning, and Non-Verbal Reasoning. Each section consists topics, like Spotting Errors or Spellings. Non-Verbal Reasoning covers topics like shape construction, embedded images and classification. You’ll find an online test you can take to assess your ability in each section.

3. Current Affairs and General Knowledge for IndiaBIX

Current Affairs and General Knowledge on IndiaBIX consists of 20 different topics, covering areas like Basic General Knowledge, World Geography, Technology, Indian Culture, Famous Personalities, Biology, and Books and Authors. When you finish the review, you can use the online test available to test your ability before taking the exam.

4. Online Tests for IndiaBIX

IndiaBIX makes it easy to find the online tests you need by grouping them together. In this section, you’ll find General Online tests, Engineering Online tests, Programming Online tests, Medical Science Online tests, and Technical Online tests. Click on any topic, and you’ll find the latest tests, the high rated tests, and the most viewed tests.

5. Interview Questions and Answers for IndiaBIX

The Interview section covers critical topics for anyone preparing for a career placement interview. You’ll find placement questions from many of the top companies, as well as suggested answers. Other sections include information on HR interview questions and answers, as well as technical questions with answers. A body language section covers how to succeed the non-verbal section of an interview. You can also share your experience with interviews, ensuring IndiaBIX stays current.

6. Puzzles for IndiaBIX

IndiaBIX offers a section on puzzles that are commonly used in career placement tests. You’ll find sudoku, missing letter puzzles, logical puzzles, playing card puzzles and more. As always, you’ll have access to the answer as well as the strategy used in answering the question.

7. Engineering for IndiaBIX

The Engineering section covers Mechanical Engineering, Civil Engineering, Chemical Engineering and the branches of Electrical Engineering like Electrical and Communication. The sections are broken down into topics like thermodynamics for mechanical engineering or fluid dynamics for chemical engineering. At the end of each section, you’ll find an online test for review.

8. Programming for IndiaBIX

The Programming section covers the primary coding languages, including (and only including) C, C++, and Java. Inside the section for each language, you’ll find topics including language fundamentals, exceptions, and objects and classes.

9. Technical Multiple-Choice Questions (MCQs) for IndiaBIX

In this section, you’ll find common MCQs used in testing. They cover technical topics like Computer Science & Engineering, Networking questions, Basic Electronics, and more. Inside most sections, you’ll find questions broken down by topics. You can also break the questions down to general questions, true and false questions, and fill-in-the-blanks. Many, but not all, sections and topics offer an online test.

10. Technical Short Answers for IndiaBIX

The Technical Short Answer section offers frequent questions asked in tests and interviews, with the answer presented immediately afterward. The answer covers the key topics that should be included in the top answers. There aren’t online tests in this section, so the section works best as a refresher before an interview or test, rather than a study guide.

Reviewing the section and topics is a great way to prepare for one of the more difficult parts of a career placement exam.

11. Medical/Science for IndiaBIX

The Medical/Science section covers Microbiology, Biochemistry, Biotechnology, and Biochemical Engineering. Inside each section, you’ll find key topics, such as glycosis and spectroscopy in microbiology, and recombinant DNA and cell cycle in biotechnology. You’ll find an online test in each section.

12. Discussion Forum for IndiaBIX

Finally, IndiaBIX includes a section for asking and answering questions – a forum section. You can ask a question on the forum, and users will answer. You can also bookmark questions to store them and look through previously answered questions. All questions come with a date. As of this review, there were more than 61,000 questions in the discussion forum. You can also rate questions.

Questions cover not only topics in the career placement exam, but also general topics covering different exams such as the IBPS recruitment exam, MPSC (Maharashtra Public Service Commission), and the BARC exam. Some users even ask for general tips or suggestions on preparing for the exam or getting good sleep before testing.

Questions are categorized by subject or topic, but the topics don’t line up exactly with the topics in the sections. This can lead to gaps when doing research. Not all questions are answered, and some answers can lead to more frustration than help.

Even so, this is a great way to get targeted help on difficult questions, with many of the answers going through the steps used to solve or answer the questions. Some questions that may not have an obvious answer, such as a theoretical or moral question, will have multiple answers so you can select the best approach for your interview or career placement exam.

Pricing for A2 Hosting


Pricing for A2 Hosting

As of now, there is no cost for using IndiaBIX, other than the online ads on the site.

Much of the information on the site is crowdsourced, with users reviewing the questions and reporting problems as they find them. Users can also add their own questions and experiences with the career placement assessments, exams and interviews. It keeps the cost low (or no cost at all) for use of the site and provides free and current updates to the information.

It does mean the site is dependent on users and user interaction, but as of now, there are many users on IndiaBIX. New questions are being added to the Discussion Forum almost daily.

But, as with any user-generated site, it does mean the information can be faulty or wrong. It may not be as current or accurate as other sites that work closely with the companies, schools or agencies to review and critique information.

Public Perception of A2 Hosting


Public Perception of A2 Hosting

Most users rate IndiaBIX extremely well.

Users consider IndiaBIX an excellent resource for exam preparation. The breakdown of subjects and topics is fantastic for quickly locating the information you need. Most report the information on IndiaBIX is accurate. Many also report the site is an excellent resource for competitive government examinations.

User friendliness is another area that is strong in user reviews. It’s easy to focus on the areas you need with IndiaBIX, rather than slogging through content and tests that aren’t relevant. Users like that the information comes from people who have taken the exam, rather than testing companies who hope you will purchase additional services.

Many report IndiaBIX is an excellent way to introduce yourself to the Competitive Examinations. You can prepare and see how ready you are before the exams. When needed, you can quickly review topics.

How IndiaBIX Compares to the Market


woman working in the laptop

Unlike other sites such as AMCAT and eLitmus, IndiaBIX doesn’t include a program to accompany the test and there is no fee. The content and information are almost completely user generated.

This can be both a strength and weakness for IndiaBIX. Users need to be aware the data is only as good as the people loading it on the site. Over time, some of the questions will age, and user updates may not be as timely, fast or current as students might like.

Sometimes, you can wait a long time for a user to answer a question on the forum. The latest information on the career placement exams and assessments may not be immediately uploaded on the site.

The raw, crowdfunded information on IndiaBIX can also be a strength. AMCAT is often seen as too easy, with information and programs designed only for the AMCAT test leaving the overall career preparation lacking. This leaves students struggling when it comes to the interview or company tests outside of the friendly confines of AMCAT. IndiaBIX provides information straight from the interviews, giving students a more complete preview of the career placement process.

What We Think of IndiaBIX


Man holding domino

IndiaBIX is a great resource for competitive exam preparation. We love the explanations offered for every answer. It’s an excellent way to not only see if you are correct, but also to work through and learn the questions you may not fully understand. You can review the questions on the site to see where you may have gaps, and then work through answers to better prepare. With the market in India improving, the extra work will help your job outlook.

It’s also a very strong tool for learning at your own pace. No matter how well designed a program may be, there will be questions and sections you don’t need. This can lead to wasted time or even mental confusion before the test.

With IndiaBIX, you can learn at your own pace, and browse through the topics and sections to find exactly the questions and answers you need. By breaking everything down into topics, sections, and questions – you can find exactly what you need every time.

Because it is crowdsourced and not designed around a program, it works best as a supplement to other tools like eLitmus. It is, by far, one of the best supplements out there.

Filed Under: Java

AMCAT Review And Pricing – What You Need To Know

June 14, 2018 by Krishna Srinivasan Leave a Comment

The AMCAT (Aspiring Minds Computer Adaptive Test) evaluates and assesses the aptitude, reasoning, and technical skills of job candidates for positions with the top MNCs (Multinational Corporation).

AMCAT, also known as the employability assessment test, is a leading career placement exam and assessment for graduating students.

As a computer adaptive test, AMCAT is effective in assessing students and job applicants on necessary workplace skills such as communication, logic, quantitative skills, and technical expertise related to their job.

AMCAT takes the standard exams and assessments further by also evaluating personality traits critical to job success. Domain skills, which can cover user workflows, business policies, system configurations, data pipelines and constraints, are also covered by the AMCAT. Modules in AMCAT cover career specific skills, allowing the assessment to be tailored for specific jobs and careers.

The results of the exam provide a statistical analysis of the student’s skills, helping companies quickly and objectively rate students and their technical skills, reasoning and ability in their chosen field.

Quick Navigation
What Makes AMCAT Unique?
1. The AMCAT Test
2. Preparation for the AMCAT
3. Mock-AI with AMCAT
4. Resume Buddy with AMCAT
5. MyEnglish with AMCAT
6. AM Certificates
7. AMCAT Hiring Services
Pricing for AMCAT and AMCAT Services
Public Perception of AMCAT
How AMCAT Compares to the Market
What We Think of AMCAT
women using laptop

AMCAT is useful not only for the companies, but also the students.

Companies can get a look at the strengths and weaknesses of job candidates before the interview process. They can pick and choose from candidates to match the needs of the business. Using the AMCAT, the company can quickly cut down on a massive candidate list and focus on only the job applicants with the highest potential success for the company. As the job market in India improves, companies want to be sure they recruit only the best candidates.

Students can use the AMCAT to assess themselves, identifying areas where they may need additional training or study. They can also use the AMCAT to select companies and careers where they have the highest potential for success, eliminating the careers and jobs that may not be appropriate.

Today, more than 700 companies use AMCAT as a testing tool for almost all entry level roles. AMCAT is working with many companies, including small and medium businesses, to help identify and prepare successful job candidates.

What Makes AMCAT Unique?


Unlike many testing companies, or even testing preparation tools like IndiaBIX, AMCAT provides a full range of services – from offering the test itself, to preparing for the test, to training programs and classes, to job placement programs after you take the test.

Conceivably, through AMCAT, you could select the career or company you want and identify the skills needed for a position. You could then sign up for classes, targeting those skills and expertise. Many classes are offered not just through AMCAT, but through the companies using AMCAT for their hiring process.

With AMCAT, you could take the preparation exams to see how well you evaluate. You can take career classes to improve your scores. Finally, you could take the AMCAT test and send your scores directly to a selected company. The entire training, job placement, and hiring process are done on the AMCAT platform. It becomes the “one-stop-shop” for career placement, as long as you have the time and resources to buy into the AMCAT program.

Let’s take a closer look at what AMCAT offers.

1. The AMCAT Test

Woman working in the computer

The base AMCAT test encompasses two areas. Everyone who takes the AMCAT will be evaluated using an Aptitude test and an AMPI (Aspiring Minds Personality Inventory) exam – the compulsory section of the AMCAT.

The Aptitude test covers English, quantitative skills and logic ability. The Aptitude test also evaluates general knowledge, including gathering and using information such as weather reports or reading an Excel spreadsheet or graph.

The AMPI questions evaluate personality. Questions cover what you might do in a situation, whether you take initiative in a given scenario, and how you might handle a variety of tasks. The focus in this section is on your openness to new experiences, how quickly you can adapt to new situations, how well you can work on a team, and your emotional stability.

After the compulsory AMCAT sections, you’ll be evaluated through skill-specific modules required for jobs and career paths. These could include computer programming, electronics and communication, civil engineering, marketing, human resources, mechanical engineering, financial services, and more. Once you’ve chosen a career path, you’ll be evaluated only on the modules that relate to your chosen career.

You can schedule AMCAT testing from the AMCAT website. The website offers multiple ways to sign up. You can select a city and then choose a site and date from a list of scheduled examination sessions. You can also put in your personal information and have AMCAT select the best session and date for your exam.

Reviewing and downloading the syllabus for every module are easy on the AMCAT site. The syllabus includes the jobs that use the module, the number of questions and duration for the module, as well as a detailed list of the skills and expertise that will be evaluated in the module.

Please note, there aren’t answers on the syllabus. The syllabus only covers the topics that could potentially be included in the questions on the exam.

amcat website

2. Preparation for the AMCAT

AMCAT offers an official AMCAT preparation test.

By signing up for AMCAT prep, you can take an official sample test from any computer. This will include not only the compulsory sections, but any skill and career specific modules you need to take. The only section not covered in AMCAT prep is the AMPI, or personality module.

Once you purchase Prep AMCAT credits, you have one month to use the credits and take the simulated AMCAT test. Once you take the test, you’ll receive your scores and evaluation that same day.

Most job applicants take the Prep AMCAT test before taking the actual AMCAT test to identify strengths and weaknesses in their testing skills and expertise. The Prep AMCAT is used to select additional classes and learning before starting the career placement testing.

3. Mock-AI with AMCAT

Once again, proving the AMCAT is more than a test. It’s also a complete program for job placement. The AMCAT offers mock interview sessions.

The Aspiring Minds Mock-AI services uses AI (Artificial Intelligence) to help prepare users for interviews. You’re sent actual interview questions to your home. You answer the questions when you’re ready, recording the answer from your webcam.

AMCAT then uses the latest machine learning technology and advanced artificial intelligence to analyze your answers. You receive a comprehensive evaluation on not just your answer, but also your body posture, voice modulations, and facial expression. The evaluation includes video snapshots you can use to identify exactly the areas you can improve, and what you are doing right.

The feedback report includes not just an evaluation, but also tips and resources for improvement.

The Mock-AI service covers not just general interview questions. It offers more than 20 different job specific interview questions.

4. Resume Buddy with AMCAT

AMCAT offers a resume service for help in creating a skill-based resume.

You can select a resume template. Once you have a template, AMCAT walks you through step-by-step how to build the resume. This includes recommendations from the companies that use AMCAT. The service includes pre-written job and skill descriptions which you can pull over to your resume.

Once you have a resume, you can also use the template to create a cover letter. The information on your resume is used as the basis for your letter.

5. MyEnglish with AMCAT

English is an important language in the global community. MyEnglish is a service through AMCAT that assesses and improves the English of users. With MyEnglish, you receive an assessment of your English speaking and writing skills. Once the evaluation and assessment is complete, you receive official AMCAT certification.

The assessment starts with a computer-based test that evaluates your writing and speaking skills. Questions are answered in both text and audio responses. The detailed evaluation of the answers covers a range of skills. Certification is offered in both written and spoken English proficiency. The evaluation can be used to both target skill improvement by identifying areas of weakness, and to prove your certification with potential employers.

6. AM Certificates

AMCAT offers skill-specific certifications covering critical job skills like Project Manager, Accounts Payable Specialist, Full Stack Developer: PHP, Data Scientist, Business Consultant, or SEO Specialist.

By signing up for a certificate, you receive an online exam. Pass the exam and you receive an official AMCAT certification which can be used on your resume and to attract potential employers.

7. AMCAT Hiring Services

AMCAT offers a range of services to help with career placement once you’ve taken the AMCAT career placement exam and you receive your test scores.

These include sharing your scores with potential employers in your chosen field. Your scores are sent directly to the company to be evaluated, and the company will reach out to schedule an interview and further testing. With partner companies, AMCAT will also set up and host interviews with prospective employees.

AMCAT also hosts Hiring Events across India where you can meet employers and hold interviews at the event. You can also find a listing of jobs on the site.

Pricing for AMCAT and AMCAT Services


Pricing for AMCAT and AMCAT Services

As of now, the basic AMCAT test costs about 900 rupees. This covers the basic, one-time exam session with the modules necessary for your career path. Please note, this cost can fluctuate depending on where you are taking the test and the career you have chosen.

There are a number of discounts that can be applied to your cost, and it is easy to receive a discount by mixing and matching the services you purchase with AMCAT.

For example, the AMCAT Premium includes the Prep AMCAT, the Resume Buddy and the Mock-AI for just ₹ 999 rupees if it is purchased on the AMCAT site. This is a discount of more than 60% and includes the actual AMCAT test for an even steeper discount. The AMCAT Premium is considered the all-inclusive job hunt kit.

There is a fee for the skill-specific certifications through AMCAT. The skill and level of certification (when there are levels of certification) will determine the cost of the certification

Public Perception of AMCAT


Man in yellow working in the computer

For graduates of tier 3 colleges or lower, the AMCAT is an excellent way to find a position with many companies and MNCs. The services are easy to use, and the program is comprehensive. It’s a fantastic resource for students who need to attract attention of employers

Many tier 3 college graduates have trouble attracting attention of top businesses after graduation. The AMCAT and AMCAT services offer graduates the edge they need to find a career, especially with companies plugged into the AMCAT pipeline.

Other users report difficulty using AMCAT. Many top companies with the most coveted positions don’t use AMCAT at all and won’t use the evaluation in selecting new employees. They see the AMCAT as too easy, and not useful in selecting employees

These companies don’t rate AMCAT graduates well, and there is a perception that the salary offered through AMCAT is lower than the salary offered by other services. Other reviews assert that companies will only use AMCAT to hire trainees or the lowest tier employees.

How AMCAT Compares to the Market


keyboard

AMCAT is a comprehensive career placement program for many different career paths. The company considers itself a testing platform with programs like Mock-AI providing fantastic service for graduates.

Other tests and services are focused on a single area and provide a better assessment. For example, eLitmus is focused on jobs in IT and software development. The focus is almost entirely on the exam, and not the resume building, interview skills, or certificates offered by AMCAT.

As a test, eLitmus is widely considered the best for IT because it is focused solely on the skills and expertise needed for IT. AMCAT offers skill modules for everything from housekeeping, to culinary arts, to mechanical engineering and medicine. This can give prospective employers a “generalist” view of AMCAT assessment.

AMCAT also focuses on not only skills, but also personality with the AMPI test. They consider it not just career placement, but employability. For many companies, this is a strength of AMCAT.

What We Think of AMCAT


Man's hand

AMCAT is a great resource for graduates looking for an entry-level position at a company. It offers a range of services that can be used in career placement, and there are many companies out there looking at AMCAT scores and willing to use them in selecting candidates for interviews.

But, if you already have experience or have an edge in capturing the attention of a prospective employer, then AMCAT isn’t a resource you need. Take a close look at your job prospects and career needs before signing up for AMCAT.

Filed Under: Java

  • « Previous Page
  • 1
  • 2
  • 3
  • 4
  • 5
  • …
  • 48
  • Next Page »

Follow Us

  • Facebook
  • Pinterest

As a participant in the Amazon Services LLC Associates Program, this site may earn from qualifying purchases. We may also earn commissions on purchases from other retail websites.

JavaBeat

FEATURED TUTORIALS

Answered: Using Java to Convert Int to String

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Copyright © by JavaBeat · All rights reserved