Java - Interview Questions and Answers for 'Java.lang' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Java.lang' - 5 question(s) found - Order By Newest

Very frequently asked in HCL Tech ( Based of 4 inputs )
  Q1. Write a Program to reverse a string iteratively and recursivelyCore Java

Ans. Using String method -

new StringBuffer(str).reverse().toString();

Iterative -

Strategy - Loop through each character of a String from last to first and append the character to StringBuilder / StringBuffer

public static String getReverseString(String str){
StringBuffer strBuffer = new StringBuffer(str.length);
for(int counter=str.length -1 ; counter>=0;counter--){
strBuffer.append(str.charAt(counter));
}
return strBuffer;
}

Recursive -

Strategy - Call the method with substring starting from 2nd character recursively till we have just 1 character.

public static String getReverseString(String str){
if(str.length <= 1){
return str;
}
return (getReverseString(str.subString(1)) + str.charAt(0);
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     string  StringBuffer  recursion  for loop  stringbuffer.append  java.lang.String  java.lang.StringBuffer  String Manipulation     HCL Technologies  Ocado  BlackRock  Oracle  FINRA  Arezzo Sky  Zalando  Boeing        frequent


 Q2. Do we need to import java.lang package ?Core Java
Anonymous
Ans. No, It is loaded by default by the JVM.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   jvm   java.lang.package   yes-no


 Q3. Name few classes that are part of java.lang package ?
Admin
info@buggybread.com
Ans. http://www.buggybread.com/2015/01/java-javalang-classes-and-interfaces.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java.lang


Rarely asked as it was introduced with Java 8.
 Q4. Name few java.lang classes introduced with Java 8 ?Core Java
Admin
info@buggybread.com
Ans. http://www.buggybread.com/2015/01/migrating-to-java-8-new-classes.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java.lang   java8   java 8


 Q5. Which java package is loaded by default and hence doesn't require an explicit import statement ?Core Java2017-06-23 08:10:46

Ans. java.lang

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java.lang  import statement      basic




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: