Matrix Java Questions: Java Questions Part 1
Download PDF of This Page (Size: 127K) ↧
Examrace Placement Series prepares you for the toughest placement exams to top companies.
-
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; } }
-
method1 ()
-
method2 ()
-
Both method1 () and method2 () takes same time for execution
ANS: (b)
Accessing method variables requires less overhead than accessing class variables.
-
-
Integer. ParseInt ( “12a” ) returns
-
Exception
-
1
-
0
-
-1
ANS: (a)
-
-
By default, Strings to functions are passed using the method
-
Call by Value
-
Call by Reference
-
Strings cannot be passed to function
ANS: (b)
String is a class defined in java. Lang and in java all classes are passed by reference.
-
-
What is the difference between OVERRIDING and OVERLOADING
-
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--); } } }
-
Goes into infinite loop
-
0, 1
-
0, 1, 2
-
None
ANS: (a)
-
-
‘t’ is the reference to a class that extends THREAD. Then how to suspend the execution of this thread?
-
t. Yield ()
-
yield (t)
-
yield ()
-
yield (100) where 100 is the milli seconds of time
-
-
What is the functionality of instanceOf ()?
-
How many String objects are created by the following statements? String str = “a + b = 10” trim (str) str. Replace ( +,)
-
1
-
2
-
3
-
4
ANS: (c)
Strings are immutable. So, for each String operation, one new object is generated.
-
-
(A program is given. I don't remember exactly) An ABSTRACT class is declared and the code is tried to instantiate it. The Question was whether it's legal to do it or not?
-
A question on “interface”
-
Cleaning operation in Java is done in the method
-
finally ()
-
finalize ()
-
final ()
-
-
Question on whether Static method can be overriden
-
How to prevent a class from being the Base Class?
-
declare it as final
-
declare it as static
-
-
If we want to read a very big text file with so many mega bytes of data, what shall we use?
-
FileInputStream
-
InputStreamReader
-
BufferedReader
-
-
One Question on Inner Classes.
-
One program on Overloading and Overriding
-
A program given using try, catch and finally and it is asked to find out which statements get executed?
-
What code, if written, below the (//code here) will display 0. Class Test { public static void main (String argv[]) { int i = 0;//code here } }
-
System. Out. Println (i + + )
-
System. Out. Println (i + ‘0’ )
-
System. Out. Println (i--)
-
System. Out. Println (i)
ANS: (a) (c), (d),
The option (b) displays the ASCII value of ‘0’ So, the output in this case is: 48
-
-
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; } } 2 Table Structures are given (Something like Employee ID, Salary, Department etc). And there are 3 queries. I remember one query. Write query to find the employees with top 5 salaries? And there 2 more theoritical SQL questions What is the difference between UNION and UNION ALL? What is the difference between COMMIT and ROLLBACK?
Technical Interview
-
Tell about yourself
-
Why do you want to leave the present company?
-
What do you know about our (Manhattan Associates) company?
-
About EJB types. CMP, BMP, Session, Entity beans, their differences, when to use what type of beans?
-
Can a Client Context call ejbRemove () method?
-
Who calls the methods ejbLoad () and ejbStore () and where the state information is stored when they are called?
-
Do you know about Sequence Diagrams in UML?
-
Which is faster in execution-JSP or SERVLET? Why?
-
What is the difference between Callable Statement and Prepared Statement?
-
Can we declare final method in abstract class?
-
Can we declare abstract method in final class?
-
What is the difference between Inner Join and Outer Join?
-
How can you pass an object of data from one JSP to another JSP? ANS: Using Session or request. GetParameter () or Hidden Variables.
-
When these methods are used? ejbActivate (), ejbPassivate () and ejbRemove ()?
-
What is the difference between ejbPassivate () and ejbRemove ()?
-
Can the same object of Stateless Session bean be shared by multiple clients?
-
Can the same object of Stateful Session bean be shared by multiple clients?
-
How do you manage transactions in EJB?
-
What is the difference between response. Redirect () and forward and request dispatcher? Which is faster?
-
In java, which has more wider scope? Default or Private?