UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Hi, Can anyone help me on below queries? 1. What makes a class as "Thread safe class" ? 2. equals() method uses 3. Difference between String vs StringBuffer ?

Asked by Last Modified  

26 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Java/J2EE, B.E./B.Tech/MCA SubjectsTraining

There are three ways to construct thread-safe Java class which has some state: 1. Make it truly immutable 2.Make field volatile. 3.Use a synchronized block
Comments

Java/J2EE, B.E./B.Tech/MCA SubjectsTraining

equals() method compares string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object. public boolean equals(Object anObject)
Comments

Java/J2EE, B.E./B.Tech/MCA SubjectsTraining

String vs StringBuffer : 1) Mutability: String is immutable (Once created, cannot be modified) while StringBuffer is mutable (can be modified). 2) Performance: While performing concatenations you should prefer StringBuffer over String because it is faster. The reason is: When you concatenate strings...
read more
String vs StringBuffer : 1) Mutability: String is immutable (Once created, cannot be modified) while StringBuffer is mutable (can be modified). 2) Performance: While performing concatenations you should prefer StringBuffer over String because it is faster. The reason is: When you concatenate strings using String, you are actually creating new object every time since String is immutable. read less
Comments

String objects are immutable in java while in StringBuffer objects u can make changes like insert ,delete or append characters
Comments

String objects are immutable in java while in StringBuffer objects u can make changes like insert ,delete or append characters
Comments

1.Defining the threading model for your application is probably the most important step you can take into making your code thread safe.You need to have your threading model down beforehand so you can actually get your code right. The reason for that is that there are a lot of different ways to make your...
read more
1.Defining the threading model for your application is probably the most important step you can take into making your code thread safe.You need to have your threading model down beforehand so you can actually get your code right. The reason for that is that there are a lot of different ways to make your class thread safe, and you can only pick the right one if you know the thread access pattern to your class. 2.This method compares 'this' string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object. 3.------------------------------------------------------------------------------- String StringBuffer ---------------------------------------------------------------------------------- Storage Area Constant String Pool Heap Modifiable No (immutable) Yes( mutable ) Thread Safe Yes Yes Performance Fast Very slow ----------------------------------------------------------------------------------- read less
Comments

Core Java Advanced Java NET GATE Computer Science

equals method is in Object class whose default implementation checks the memory location of the objects which is similar to ===. The String class has overridden the equals method and new implementation checks the string content present in the object. One has to override the hashcode(in Object class)...
read more
equals method is in Object class whose default implementation checks the memory location of the objects which is similar to ===. The String class has overridden the equals method and new implementation checks the string content present in the object. One has to override the hashcode(in Object class) method too when override the equals method. read less
Comments

Founder Win Corporate Training IT Corporate Trainer/Coach, Counsellor

String class is used create the immutable strings in Java. For Example: String str=new String("Good"); - If I want to add the word "Morning" I have to recreate my String class Object. String str=new String("Good Monring"); StringBuffer is used to create the Mutable Strings in Java StringBuffer...
read more
String class is used create the immutable strings in Java. For Example: String str=new String("Good"); - If I want to add the word "Morning" I have to recreate my String class Object. String str=new String("Good Monring"); StringBuffer is used to create the Mutable Strings in Java StringBuffer str1=new StringBuffer("Good"); str1.append("Monring"); We can add the new word without creating the object of the String class. read less
Comments

Software Engineer

1. What makes a class as "Thread safe class"? Thread safe class: If your class is being accessed by multiple threads then there is a possibility that class variable/properties may be accessed or changed by two or more thread simultaneously which may result in inconsistent behaviour of class. The process...
read more
1. What makes a class as "Thread safe class"? Thread safe class: If your class is being accessed by multiple threads then there is a possibility that class variable/properties may be accessed or changed by two or more thread simultaneously which may result in inconsistent behaviour of class. The process of preventing this is called as Thread safe. Process to make class thread safe: Use Synchronized Methods/blocks to prevent access of class properties by multiple threads. Use of Volatile keyword so that properties changed by one thread will immediately reflect to all other places. 2. equals() method uses equals method is used in Java to equate different Objects of Class. 3. Difference between String vs StringBuffer? String is immutable while StringBuffer is mutable. Mutable means state of object can be changed, while state of immutable can not be altered. read less
Comments

StringBuffer outdated , use StringBuilder thread safe,
Comments

View 24 more Answers

Related Questions

I am mechanical student. Can you please tell me opportunities in software field?
Yes, you can get an opportunity. I have seen many mechanical, chemical and biotechnology students are working in its sector. For that, you have to learn some IT courses.
Sainathgowd
Should we learn DBMS and RDBMS without any Java training?
java or i can say any programming language is not required to learn DBMS or RDBMS
Karthik
0 0
6
Is it really needed to do Java training before graduation, to get a job?
Yes, It's must to get better opportunities and to standard alone in IT field. Not only core Java but also learn Spring,Hinernat ,Struts. ANGULARJS add an advantage to get job easily.
Udaybhan
What are Access Specifiers in Java?
There are no access specifiers in java as like in c++. Now you can think that, public, private protected and default are what all these. These all called as access modifiers. Everywhere these four...
Kadar
0 0
9
Can we use pointer in java?
No, we can't. Java has reference variables which contains address of objects. The reference variables are substitute to pointers in java. But, we cannot perform mathematical operations on reference variables...
Manish

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Recommended Articles

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more