Future Vision BIE Future Vision BIE


ONE STOP FOR ALL STUDY MATERIALS & LAB PROGRAMS


E MENU Whatsapp Share Join Telegram, to get Instant Updates
×

NOTE!

Click on MENU to Browse between Subjects...

Advertisement

17CS553 - ADVANCED JAVA AND J2EE

Answer Script for Module 3

Solved Previous Year Question Paper

CBCS SCHEME


ADVANCED JAVA AND J2EE

[As per Choice Based Credit System (CBCS) scheme]

(Effective from the academic year 2019 -2020)

SEMESTER - V

Subject Code 17CS553
IA Marks 40

Number of Lecture Hours/Week 03
Exam Marks 60



Advertisement

These Questions are being framed for helping the students in the "FINAL Exams" Only (Remember for Internals the Question Paper is set by your respective teachers). Questions may be repeated, just to show students how VTU can frame Questions.

- ADMIN




× CLICK ON THE QUESTIONS TO VIEW ANSWER

insert( )

The

insert( )

method inserts one string into another. It is overloaded to accept values of all the simple types, plus

String

s,

Object

s, and

CharSequence

s. Like

append( )

, it calls

String.valueOf( )

to obtain the string representation of the value it is called with. This string is then inserted into the invoking

StringBuffer

object. These are a few of its forms:

StringBuffer insert(int index , String str )

StringBuffer insert(int index , char ch )

StringBuffer insert(int index , Object obj )

Here, index specifies the index at which point the string will be inserted into the invoking

StringBuffer

object.

The following sample program inserts “like” between “I” and “Java”:

Loading Image



Advertisement

append( )

The

append()

method concatenates the string representation of any other type of data to the end of the invoking

StringBuffer

object. It has several overloaded versions. Here are a few of its forms:

StringBuffer append(String str )

StringBuffer append(int num )

StringBuffer append(Object obj )

String.valueOf( )

is called for each parameter to obtain its string representation. The result is appended to the current

StringBuffer

object. The buffer itself is returned by each version of

append( )

.

Loading Image


replace( )

You can replace one set of characters with another set inside a

StringBuffer

object by calling

replace()

. Its signature is shown here:

StringBuffer replace(int startIndex , int endIndex , String str ) The substring being replaced is specified by the indexes startIndex and endIndex. Thus, the substring at startIndex through endIndex –1 is replaced. The replacement string is passed in str.

The resulting

StringBuffer

object is returned.

The following program demonstrates

replace( )

:

Loading Image



Advertisement

substring( )

You can obtain a portion of a

StringBuffer

by calling

substring( )

. It has the following two forms:

String substring(int startIndex )

String substring(int startIndex , int endIndex )

The first form returns the substring that starts at startIndex and runs to the end of the invoking

StringBuffer

object. The second form returns the substring that starts at startIndex and runs through endIndex


BASIS FOR COMPARISON

STRING

STRINGBUFFER

Basic

The length of the String object is fixed.

The length of the StringBuffer can be increased.

Modification

String object is immutable.

StringBuffer object is mutable.

Performance

It is slower during concatenation.

It is faster during concatenation.

Memory

Consumes more memory.

Consumes less memory.

Storage

String constant pool.

Heap Memory.

StringBuffer Constructors

StringBuffer( ):

It reserves room for 16 characters without reallocation.

StringBuffer s=

new

StringBuffer();

StringBuffer( int size)

It accepts an integer argument that explicitly sets the size of the buffer.

StringBuffer s=

new

StringBuffer(20);

StringBuffer(String str):

It accepts a

String

argument that sets the initial contents of the StringBuffer object and reserves room for 16 more characters without reallocation.

StringBuffer s=

new

StringBuffer("FutureVisionBIE");

Loading Image


× NOTE: Each Page Provides only 5 Questions & Answer
Below Page NAVIGATION Links are Provided...
All the Questions on Question Bank Is SOLVED

Advertisement



× SUGGESTION: SHARE WITH ALL THE STUDENTS AND FRIENDS -ADMIN

Instagram :
×



Follow our Instagram Page:
FutureVisionBIE
https://www.instagram.com/futurevisionbie/

Message: I'm Unable to Reply to all your Emails
so, You can DM me on the Instagram Page & any other Queries.