![]() |
| 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. What is the output of following program ?class Test { public static void main(String args[]) { for(int i=0;i<2;i++) { System.out.println(i); } } }(a) Goes into infinite loop (b) 0,1 (c) 0,1,2 (d) None (a) 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. ... What is the better way of writing the Constructor with 2 parameters in the following code:class Test What is the better way of writing the Constructor with 2 parameters in the following code:class Test { int x,y; Test(int a) { //Code for very complex operations will be written //in this place x=a; } Test(int a, int b) { //Code for very complex operations will be written //in this place (same code as in above constructor) x=a; y=b; } }
Sponsored Links
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||