Java for Testers – Interview Questions and Answers Part-14 1) Write a Java Program to print the below output: * 1 * 12 * 123 * 1234 * 12345 * 123456 * 1234567 public class Patterns { public static void main(String[] args){ int c = 2; int num = 1; System.out.print("*" + " " +…
Java for Testers – Interview Questions and Answers Part-13 1) Java Program: Change a string such that first character is upper case, second is lower case and so on? public static String changeToUpperCase(String str) { StringBuffer s = new StringBuffer(); char ch = ' '; for (int i = 0; i < str.length(); i++) {…
Java for Testers – Interview Questions and Answers Part-12 1) Explain about Diamond problem in Java? The “diamond problem” is an ambiguity that can arise as a consequence of allowing multiple inheritance. The problem occurs when there exist methods with same signature in both the super classes and subclass. On calling the method, the compiler…
Java for Testers – Interview Questions and Answers Part-11 1) What is verbose? Verbose is an option that can be used on the Java command to enable debug output for class loading. 2) What is thread count? The Thread Count parameter specifies the maximum number of simultaneous requests the server can handle. When the server…
1) What is the difference between static variables and instance variables? Answer: The below is the answer for this question: static variables are common variables who’s values will be stored in Class memory. instance variables are object specific variables who’s values will be stored in individual object’s memory. For detailed answer with practical examples and…
1) What are Primitive and Non-Primitive Data Types? Answer: The below is the answer for this question: Data Types that are non-object oriented are know as Primitive Data Types. Examples for Primitive Data Type: byte,short,int,long,float,double,char and boolean Data Types that are object oriented are known as Non-Primitive Data Types. Examples for Non-Primitive Data Type: String,…
1) What are the differences between methods and constructors? Answer: The below is the answer for this question: When compared to Methods: 1. Constructors won’t have any return type 2. Constructors should have the same as the Class name 3. Constructors are automatically called when objects are created For detailed answer with practical examples and…
1) What is the difference between == and equals()? Answer: The below is the answer for this question: == operator compares the string objects, where as equals() function compares the text stored in the string objects. public class Demo{ public static void main(String[] args) { String a = new String("Hello" ); String b = new…
1) What is the output of System.out.println(10+20+”Hello”+”World”);? Answer: The below is the answer for this question: public class Demo{ public static void main(String[] args) { System.out.println(10+20+"Hello"+"World"); } } Output: 30HelloWorld For detailed answer with practical examples and explanation of this answer, you can check the below youtube video: 2) What is the output of System.out.println(“Hello”+”World”+10+20);? Answer:…
1) Is String a data type? Answer: The below is the answer for this question: String is a predefined Class in Java, and hence it is not a data type. For detailed answer with practical examples and explanation of this answer, you can check the below youtube video: 2) What is the difference between Print…