CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies

Search Interview Questions

Question: What is the difference between length and length() ?

Answer:



Category Java Interview Questions & Answers - Exam Mode / Learning Mode
Rating (3.6) By 91 users
Added on 5/20/2013
Views 1495
Rate it!
Question: What is the difference between length and length() ?
Answer:

Source: CoolInterview.com


length() is function which is defined for string class whereas length is used only for array. Source: CoolInterview.com

Answered by: seema pawar | Date: 5/23/2008 | Contact seema pawar Contact seema pawar

Both returns an int value.length parameter is used with String array to get the number of elements of array and length()method is used with String Buffer to get the length. Source: CoolInterview.com

Answered by: Daliya | Date: 5/27/2008 | Contact Daliya Contact Daliya

length - keyword , find out the array length

// length() - method , find out the String length Source: CoolInterview.com

Answered by: vishal singh | Date: 7/11/2008 | Contact vishal singh Contact vishal singh

length()is a method that is defined in String class whenever length is a property of array that is defined in JVM. because in java array is dynamic , means array are object and contain memory at runtime. Source: CoolInterview.com

Answered by: Tarique Anwer | Date: 11/18/2009 | Contact Tarique Anwer Contact Tarique Anwer

length is an instance variable of array and it returns the number of elements in that array, while length() is a method of String class. length() method returns the length of the string which is equal to the Unicode code units in that string. Source: CoolInterview.com

Answered by: Sandeep Bhardwaj | Date: 1/21/2010 | Contact Sandeep Bhardwaj Contact Sandeep Bhardwaj

length - Used to find the length of array.

length()- Used to find the length of String Source: CoolInterview.com

Answered by: Karthick | Date: 2/21/2010 | Contact Karthick Contact Karthick

length : it is a keyword which is used for find out length for an array..
lensth() : its is a method in java to find out the length of the stringclass .......... Source: CoolInterview.com

Answered by: lakshmareddy | Date: 3/5/2010 | Contact lakshmareddy Contact lakshmareddy

length()- is a static method of String class and will return no. of characters present in a string.

length- will give the length ie. no. of elements stored in an array.

public class Len
{
public static void main(String args[])
{
String x="abc";
int a[]={1,2,3,4};
System.out.println(x.length());
System.out.println(a.length);
}
}

output will be
3
4



Source: CoolInterview.com

Answered by: NEERAJ KUMAR SINHA | Date: 3/26/2010 | Contact NEERAJ KUMAR SINHA Contact NEERAJ KUMAR SINHA

length - keyword ,to find out the array length
length() - method , to find out the String length. Source: CoolInterview.com

Answered by: prakash | Date: 4/1/2010 | Contact prakash Contact prakash


If you have the better answer, then send it to us. We will display your answer after the approval

Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.

Post your answer here

Inform me about updated answers to this question.
Related Questions
View Answer
What is the difference between concat and append?
View Answer
What is the difference between Java and J2EE? Is J2EE advanced version of Java?
View Answer
How do u create objects at runtime?
View Answer
What is a string Handling? How to use it? what is difference b/w Event handling?
View Answer
What is multi threading ?
View Answer
What are the main differences between
jdk1.4 n jdk1.5?
View Answer
Given A = 1, B = 2, C = 3, D = 4 ?? Z = 26, write a java standalone
program to encode the word ?TELEPHONE? into numbers.
View Answer
Write a java standalone program / method to take out all the special
characters in the string provided below.
//ASCII a ? z (97 ? 122)
String sSENTENCE = ?This!is^a$t*e)s|t?;
View Answer
Why pointers are not used in java?
View Answer
What is super class of an Exception class?
View Answer
What is super class of an Exception class?
View Answer
Why JAVA not support multiple inheritance? How can we pass address of an object?
View Answer
In How many ways we can request the System for the garbage collection to cleanup the memory? And what are the differences?
View Answer
Why java is not pure object oriented language?
View Answer
what is the definition of arraylist? plz write in brief.
View Answer
1)What are the actual functions of JVM?
2)When to use a class and when to use
an Abstract class?
3)what is the use of constructors other than creation of objects?
4)when to use constructors?
5)when to use Interface?
6)why java does not support pointers?
7)why multiple inheritance is not possible in java without using Interfaces?
View Answer
Why we have used to in main method in JAVA this words
1)public
2)static
3)void
4)main
5)(String args[])
View Answer
Addition of two numbers using Bitwise operators.
Reading An 2D array using single for loop
View Answer
What is UML patterns?give me clear explanation
View Answer
While developing one in JSP page we are sending request to Struts frame work.If we click two times submit button then First time only it should accept request and second time should reject that request in struts frame work.

How we can do that in controller itself...I am waiting for your Response...

View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View All Java Interview Questions & Answers - Exam Mode / Learning Mode




India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.032104 Seconds