Hi Developers, Here is the article to all tricky java interview Question with answer that asked by many company. Let’s Enjoy all technical type of interview Questions.
Question 1 :
Answer Explanation : Correct Answer 0 because variable i is never initialized to,and will always have its default value 0. The default constructor is invoked implicitly if there is no constructor in the class, the variable i is initialized to 0.
Question 2 :
Code Details : The ASCII of i = 115 and 116.0 + 115 = 121.0 Correct Answer.Char datatypes is the sub-datatype of float.So that no error.
Question 3 :
Code Explanation : Assignment operator: It perform Shallow copying operation. The Shallow copy can be made by simply
copying the reference. str2 simply refers to the same array as str1. Clone Method.It perform Deep copying operation.
Deep copying means creating a new array and copying over the values. str2 refers to the different array as str1. Correct Answer 3.
Question 4 :
Test.main(String) and main(Object) has the wrong signature to be an entry point. The Correct Signature Test.main(string args) , so the output display String Array Method.
Correct Answer 2.
Question 5 :
null Represents the empty string. so, fun(null) call fun(String s) method. then output display String . Correct Answer 1.
Correct Answer 3. In String pool Strings st1 and st2 generate same memory address because its string literal and values same but for Strings objects str1 and str2 generate different memory address. so we cant compare.
Question 7 :
Correct Answer 4. why i’ll explain later.