Posts

Showing posts from May, 2019

Java Interview Questions updated on May 2019

Java Interview Questions updated on May 2019 1.What is JVM? The Java interpreter along with the runtime environment required to run the Java application in called as Java virtual machine(JVM) 2. What do you mean by platform independence? Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc). 3. What is the difference between a JDK and a JVM? JDK is Java Development Kit which is for development purpose and it includes execution environment also. But JVM is purely a run time environment and hence you will not be able to compile your source files using a JVM. 4. What is the most important feature of Java? Java is a platform independent language. 5. What is the base class of all classes? java.lang.Object 6. What are the states associated in the thread? Thread contains ready, running, waiting and...

string-is-palindrome

string-is-palindrome Question: Implement a method that checks whether a string is a palindrome or not. problem is to break the String into a char array, then comparing the chars from two ends. This algorithm runs in O(n) time. Java public static boolean isPalindrome ( String input ) { // Break into a char array char [ ] charArray = input . toCharArray ( ) ; // Compare front and end character until meet at middle for ( int i = 0 , j = charArray . length - 1 ; i < charArray . length / 2 ; i ++ , j -- ) { if ( charArray [ i ] != charArray [ j ] ) return false ; } return true ; }