answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

What is difference between String str and String s equals new String?

Btw, this is a C++ question. in 'String str', str is an object and most probabily (based on most String implementations) we can use str = "my name"; int len = str.length(); String s = new String; <== this is something wrong. it should be String *s = new String; here 's' is a pointer and the object is allocated/instanciated by 'new' operator you can use it *s = "my name" int len = s->length()


Difference between char pointer and char buffer?

The difference here is that char *p = "Hello"; will place Hello world in the read-only parts of the memory and making p a pointer to that, making any writing operation on this memory illegal. While doing: char p[] = "Hello"; puts the literal string in read-only memory and copies the string to newly allocated memory on the stack. p[0] = 'A'; is legal.


What happens when your compare two string objects with the equals operator?

Yes, the if the two string objects point to the same memory location. But "==" is not the best way to compare two string objects. Two strings can be compared using obj1.equals(obj2). This compares for the textual equal-ness of the two string objects.


How is a 20 byte string value stored in memory?

As a 21 byte array of type char (including 1 byte for the null terminator).


What is difference between System.String and System.StringBuilder classes?

String and StringBuilder classes are used to store string values but the difference in them is that String is immutable (read only) by nature, because a value once assigned to a String object cannot be changed after its creation. When the value in the String object is modified, a new object is created, in memory, with a new value assigned to the String object. On the other hand, the StringBuilder class is mutable, as it occupies the same space even if you change the value. The StringBuilder class is more efficient where you have to perform a large amount of string manipulation.

Related Questions

What is the purpose of the head string pool in a programming language and how does it impact memory management?

The purpose of the head string pool in a programming language is to store and manage commonly used string literals in memory. This helps reduce memory usage by reusing the same string objects instead of creating new ones every time they are used. This can improve memory management by reducing the amount of memory allocated for storing duplicate string literals, leading to more efficient use of memory resources.


When does the memory created for an object?

Memory for a Java object gets created when the object is instantiated. For example private String name = "rocky"; At the end of this statement the memory for the string object name gets created in the memory.


What is the memory space occupied by string unlimited?

In programming, an "unlimited" string typically refers to a string data type that can grow as needed, often implemented using dynamic memory allocation. The memory space it occupies depends on the length of the string at any given time, along with any overhead for managing the memory (like length metadata). Therefore, there isn't a fixed memory size; it expands as more characters are added, limited only by the system's available memory.


What are array of string pointers?

An array of pointers to string would contain, per array position, a number dictating which memory address holds the string data. For example, position [0] in an array would contain a memory address. This memory address can be de-referenced to obtain the actual information held within that memory address.


Why memory to memory acess is not possible in 8086 micro processor?

Memory to memory access is certainly possible in the 8086/8088 microprocessor. Look at the repeated string copy instructions.


What is immutable means in java?

immutable means we can't change the content of string object Example:String name = "Tommy"; String fullName = name + "Junior";Here when we declared fullName you would expect it to be appended to the system memory location where the variable name is saved. But in Java it does not happen this way.Here a new variable fullName would be created in memory and the value would be saved there.This is termed as immutable. i.e., String objects cannot be modified in memory once they are created. You may be able to view the change in your program but new String objects would be created in the system memory.Tip:If you want to modify your String objects, then it is advisable to use a StringBuffer instead of a String. StringBuffer allows us to modify string objects and they would be saved in only one place in the system memory. Hence the memory utilization of the system would be much better than the normal String.


What is difference between String str and String s equals new String?

Btw, this is a C++ question. in 'String str', str is an object and most probabily (based on most String implementations) we can use str = "my name"; int len = str.length(); String s = new String; <== this is something wrong. it should be String *s = new String; here 's' is a pointer and the object is allocated/instanciated by 'new' operator you can use it *s = "my name" int len = s->length()


How much memory is required to store a 'character' and how much is required to store a 'string'?

a character/byte as defined in the C programming language is one byte (8 bits). A string can be as short as one byte and can be as long as the physical memory limits can contain it.


How a virus is removed from disk?

You can check your hard disk's memory and search string by string for the virus, or if you don't want to spend that time, format it. Although the latter will delete EVERYTHING.


Difference between char pointer and char buffer?

The difference here is that char *p = "Hello"; will place Hello world in the read-only parts of the memory and making p a pointer to that, making any writing operation on this memory illegal. While doing: char p[] = "Hello"; puts the literal string in read-only memory and copies the string to newly allocated memory on the stack. p[0] = 'A'; is legal.


How is a virus removed from your hard-disk?

You can check your hard disk's memory and search string by string for the virus, or if you don't want to spend that time, format it. Although the latter will delete EVERYTHING.


Can both operand 1 and operand 2 be memory in 8086?

Yes, both operand 1 and operand 2 can be in memory in the 8086. An example is the string copy primative, which takes source and destination operands to be memory pointed to by DS and ES.