![]() |
| Home | Tech FAQ | Interview Questions | Placement Papers | Tech Articles | Learn | Freelance Projects | Online Testing | Geeks Talk | Job Postings | Knowledge Base | Site Search | Add/Ask Question |
![]() Related Questions Which of the following 2 methods executes faster ?class Trial { String _member; void method1() { for(int i=0;i<2048;i++) { _member += "test"; } } void method2() { String temp; for(int i=0;i<2048;i++) { temp += "test"; } _member = temp; } } (a) method1() (b) method2() (c) Both method1() and method2() takes same time for execution (b)Accessing method variables requires less overhead than accessing class variables. By default, Strings to functions are passed using the method(a) Call by Value (b) Call by Reference (c) Strings cannot be passed to function (b)String is a class defined in java.lang and in java all classes are passed by reference. How many String objects are created by the following statements ?String str = " a+b=10 "; trim(str) str.replace(+,-);(a) 1 (b) 2 (c) 3 (d) 4 (c)Strings are immutable. So, for each String operation, one new object is generated. Latest Answer : protected void finalize() method is called by the garbage collector just before it is about to reclaim the memory space acquired by the object. ... Latest Answer : Static Methods over loading is of no use for example the below code will produce a output of B.m1 C.m1 C.m1 if we remove static in those functions we will get an ouput of B.m1 C.m1 B.m1 class C{ static ... Latest Answer : yes answer is final it wou't give chance to other to modify. it prevant to other to chace the class. ... A program given using try, catch and finally and it is asked to find out which statements get executed ?
Sponsored Links
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||