Exception handling is the technique of catching the exceptions that might be thrown some time in the future during runtime. Java offers robust exception handling solutions with the try-catch-finally construct. One of the most remarkable exception is when, during program execution, the time comes for a division by zero. This cannot be done and, therefore, Java throws an exception, specifically the ArithmeticException.
2. What's the purpose of the finally clause of a try-catch-finally statement?
A finally clause can be added to force the exception of statements that perform necessary cleanup.
3. Tell me about a case that finally cluase will be not executed?
There is none.
4. Name some OO design patterns you have used and how/why you used them?
TO-DO
Singleton? Abstract Factory?
Hibernate SessionFactory is singleton??
Spring framework is Proxy??
5. What is a Singleton?
a. It proposes that at any time, there can only be one instance of a singleton (object) created by the JVM.
b. The class's default constructor is made private, which prevents the direct instantiation of the object by other classes. At static modifier is applied to the instance method that returns the object as it then makes this method a class level method that can be accessed without creating an object.
c. Singletons can be used to create a Connection Pool. If programmers create a new connection object in every class that requires it, then it's clearly waste of resources. In this scenario by using a singleton connection class we can maintain a single connection object which can be used throughout the application,
6. What is a transient variable and why would you use one?
A variable that may not be serialized. (Temporary state of the object which need not be saved, something like process ID, or Time information)
7. What is serialization?
Serialization is a mechanism for persisting and retrieving an object, including its state to/from the persistant storage.
(http://619lucky.blogspot.com/2010/09/java-serializable-string-object-is.html)
String object also implements Serializable interface. Serializable interface doesn't have any mothed.
8. What are the components of JDBC?
Connection pool, data sources, statement, ResultSets.
9. What is a bind variable (for JDBC) and why should they, or should they not, be used?
A placeholder for a variable in a query.... should almost always be used to reduce the number of query parses executed by the database.
10. When do you use a Statement vx. a CallableStatement vs. a PreparedStatement?
CallableStatement for procedures.
PrepatedStatemnt for queries using bind variables.
Statement for non bound (no bind variable) queries.
11. What is a DataSource?
Interface javax.sql.DataSource
DataSource is a factory for connections to the physical data source that DataSource factory represents.
DataSource is the preferred means of getting a connection.
An object that implements DataSource will usually be registered with a naming service based on the JNDI (Java Naming and Directory API)
(http://download.oracle.com/javase/1.4.2/docs/api/javax/sql/DataSource.html)
12. What is connection pool?
When use a SQL ot other similar tool to connect to that database and act on the data, "getting the connection" and "logging in" is the part that takes the most of the time.
Cached connections are kept in a runtime object pool and can be used and reused as needed by the application. One way to implement the object pool is to make a simple hashtable of connection objects. However, a more flexible way to do it is to write a wrapper JDBC Driver that is an intermediary between the client application and database.
(http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html)
.....
13. What's a reasonable limit on connection pool size for an average single application server?
I don't know.... 20?
....
14. Can that many connections cause problems for a database?
Yes(?) If the connection is persistent...?
(http://blog.powercam.cc/xms/doc/724)
(http://www.coderanch.com/t/216774/ORM/java/Too-many-Connections-Exception)
15. Is there a maximun number of connections limit defined in the database?
How do you change it?
( I don't know )
16. What is the Connections API and what are the advantange of using it?
The Connections framework provides a well-designed set for sorting and manipulating a group of data (a collection).
(http://www.allapplabs.com/java/java_collection_framework.htm)
a. The collection interface is a group of objects, which duplicates allowed.
b. Set extends Collection but NOT allow duplicates.
c. List extends Collection also, it allows duplicates and introduces positioning indexing.
d. Map extends neither Set nor Collection.
interface
18. What's the difference between a HashSet and an ArrayList?
HashSet can't have duplicate key/value, ArrayList can.
19. What's the difference between a HashSet and a HashMap?
a. HashSet doesn't allow duplcate, it maintains a unique list.
b. HashMap allows null for both keys and value, it's unsynchronized.
A HashMap provides fast access to a mapping from a unique key to a value. Keys are unordered which makes it faster than the TreeMap where the keys are ordered.
A HashSet is fast access to unique value only (there are no keys because it is not a mapping it's just the values). HashSet values are unordered which makes it faster than the TreeSet where the values are ordered.
20. Give an example of when you would use a HashMap?
If you may have null value in the collection, and the keys are unique but not in order...
21. What object do you use to determine if a user posesses a J2EE Role?
HttpRequest
22. What's the difference between an Integer and an int?
Object/Primitive
Object is using memory in Heap, Primitive is using memory in Stack.
(Check out Heap/Stack http://619lucky.blogspot.com/2010/09/java-stack-and-heap.html)
23. What methods are available on an int?
none.
23. What class do you use to convert between Integers, ints and Strings?
Integer
24. Are the methods you use to convert between Integers and ints class methods or instance methods?
Class method.
25. What does it mean for a method to be static?
Static methods use no instance variables of any object of the class. if you define a method to be static, you will be given a rude message by the compiler if you try to access any instance variables. You can access static variables, but except for constants.
Static methods typically take all the data from parameters and compute something from those parameters (with no reference to variables).
Static method is typical of methods which do some kind of generic calculation. A good example of this are the many uility methods in the predefined Math class.
宣告 method 時,如果前面加上 static 的修飾字,就會使得此 method 變成是 class method。對 class method 而言,永遠只佔用一塊記憶體,而且此記憶體空間是在此 class 一被載入進記憶體之後就立刻配置的,就如同此 method 是與該 class 本身相關,而不是與該 class 的 instance 相關。
26. What class do you use to manipulate Date objects in Java?
Calendar
27. What class do you use to format Date objects in Java?
DateFormat(abstract class) or SimpleDateFormat -subclass of DateFormat.
28. What is the difference between SAX based and DOM based XML parsing?
SAX is event based. DOM is tree navigation based.
29. When would you use one over the other?
SAX for XML based event processing. Large documents or memory constrained System.
DOM for XML document editing.
30. Tell about any XML binding tools you've used, or any other parsing techniques.
JAXB (Marschalling and UnMarshalling, Factory)....(?)
31. Schema and DTD
?????
32. What must a class do to implement an interface?
It must provide all of the methods in the interface and identify the interface in its implements clause.
33. What is an interface and what are they used for?
a. Capturing similarities among unrelated classes without arficially forcing a class relationship.
b. Declaring methods that one or more classes are expected to implement.
c. Revealing an object's programming interface without revealing its class.
34. Let's make up a system where we need to track electricity usage in a building. We have some objects that consume electricity (Monitor and Printer). We want to add an interface to the system that will define a method for determining the monitor or printer's electrical consumption.
Question: What should be a good name for this interface?
Answer: (通常是形容詞)something like Powerable, PluggedIn, ElectricityConsumer
Question: What would be a good name for a method in this interface and what would the method do?
Answer: (通常是動詞)getConsumption() returns the amount of power consumed.
Question: Let's create an Exception that will be thrown by the getConsumption method when the object is not plugged in. What's good name for that exception?
Answer: NotPluggedInException. PlugInFailException.
35.
13. What's a reasonable limit on connection pool size for an average single application server?
I don't know.... 20?
....
14. Can that many connections cause problems for a database?
Yes(?) If the connection is persistent...?
(http://blog.powercam.cc/xms/doc/724)
(http://www.coderanch.com/t/216774/ORM/java/Too-many-Connections-Exception)
15. Is there a maximun number of connections limit defined in the database?
How do you change it?
( I don't know )
16. What is the Connections API and what are the advantange of using it?
The Connections framework provides a well-designed set for sorting and manipulating a group of data (a collection).
(http://www.allapplabs.com/java/java_collection_framework.htm)
a. The collection interface is a group of objects, which duplicates allowed.
b. Set extends Collection but NOT allow duplicates.
c. List extends Collection also, it allows duplicates and introduces positioning indexing.
d. Map extends neither Set nor Collection.
Interface | Implementation | Historical | |||
Set | HashSet | TreeSet | |||
List | ArrayList | LinkedList | Vector Stack | ||
Map | HashMap | Treemap | Hashtable Properties |
ArrayList是List(列表),数据是有序的,可以有重复元素 HashSet是Set(集合),数据没有顺序,没有重复元素,元素搜索速度快17. Is Iterator inthe Collections API a class or an interface?
interface
18. What's the difference between a HashSet and an ArrayList?
HashSet can't have duplicate key/value, ArrayList can.
19. What's the difference between a HashSet and a HashMap?
a. HashSet doesn't allow duplcate, it maintains a unique list.
b. HashMap allows null for both keys and value, it's unsynchronized.
A HashMap provides fast access to a mapping from a unique key to a value. Keys are unordered which makes it faster than the TreeMap where the keys are ordered.
A HashSet is fast access to unique value only (there are no keys because it is not a mapping it's just the values). HashSet values are unordered which makes it faster than the TreeSet where the values are ordered.
20. Give an example of when you would use a HashMap?
If you may have null value in the collection, and the keys are unique but not in order...
21. What object do you use to determine if a user posesses a J2EE Role?
HttpRequest
22. What's the difference between an Integer and an int?
Object/Primitive
Object is using memory in Heap, Primitive is using memory in Stack.
(Check out Heap/Stack http://619lucky.blogspot.com/2010/09/java-stack-and-heap.html)
23. What methods are available on an int?
none.
23. What class do you use to convert between Integers, ints and Strings?
Integer
24. Are the methods you use to convert between Integers and ints class methods or instance methods?
Class method.
25. What does it mean for a method to be static?
Static methods use no instance variables of any object of the class. if you define a method to be static, you will be given a rude message by the compiler if you try to access any instance variables. You can access static variables, but except for constants.
Static methods typically take all the data from parameters and compute something from those parameters (with no reference to variables).
Static method is typical of methods which do some kind of generic calculation. A good example of this are the many uility methods in the predefined Math class.
宣告 method 時,如果前面加上 static 的修飾字,就會使得此 method 變成是 class method。對 class method 而言,永遠只佔用一塊記憶體,而且此記憶體空間是在此 class 一被載入進記憶體之後就立刻配置的,就如同此 method 是與該 class 本身相關,而不是與該 class 的 instance 相關。
26. What class do you use to manipulate Date objects in Java?
Calendar
27. What class do you use to format Date objects in Java?
DateFormat(abstract class) or SimpleDateFormat -subclass of DateFormat.
28. What is the difference between SAX based and DOM based XML parsing?
SAX is event based. DOM is tree navigation based.
29. When would you use one over the other?
SAX for XML based event processing. Large documents or memory constrained System.
DOM for XML document editing.
30. Tell about any XML binding tools you've used, or any other parsing techniques.
JAXB (Marschalling and UnMarshalling, Factory)....(?)
31. Schema and DTD
?????
32. What must a class do to implement an interface?
It must provide all of the methods in the interface and identify the interface in its implements clause.
33. What is an interface and what are they used for?
a. Capturing similarities among unrelated classes without arficially forcing a class relationship.
b. Declaring methods that one or more classes are expected to implement.
c. Revealing an object's programming interface without revealing its class.
34. Let's make up a system where we need to track electricity usage in a building. We have some objects that consume electricity (Monitor and Printer). We want to add an interface to the system that will define a method for determining the monitor or printer's electrical consumption.
Question: What should be a good name for this interface?
Answer: (通常是形容詞)something like Powerable, PluggedIn, ElectricityConsumer
Question: What would be a good name for a method in this interface and what would the method do?
Answer: (通常是動詞)getConsumption() returns the amount of power consumed.
Question: Let's create an Exception that will be thrown by the getConsumption method when the object is not plugged in. What's good name for that exception?
Answer: NotPluggedInException. PlugInFailException.
35.
No deposit bonuses 2021 - Casinowed.com
回覆刪除Best no deposit casino bonus codes for 2021 - We list the latest no deposit ラッキーニッキー casino bonuses, free starvegad spins offers and more.Casinoworld Bonuses 퍼스트카지노 · The Best Free Spins Bonuses · No Deposit