What Are The Components of Web Service?: Java Questions
What Are The Components of Web Service?: Java Questions
Example
1. object MainObject {
2. def main(args: Array[String]) = {
3. var result1 = (a:Int, b:Int) => a+b // Anonymous func
tion by using => (rocket)
4. var result2 = (_:Int)+(_:Int) // Anonymous functio
n by using _ (underscore) wild card
5. println(result1(10,10))
6. println(result2(10,10))
7. }
8. }
Example
1. object MainObject {
9. def main(args: Array[String]) {
10. var result = functionExample() // Calling function
11. println(result)
12. }
13. def functionExample() = { // Defining a function
14. var a = 10
15. a
16. }
17. }
6.
How can you avoid importing tables one-by-one
when importing a large number of tables from a
database?
7.
It’s a class which is nested within another class. It’s a class which inherits from
another class called super class.
Inner class provides the access rights for the class Sub-class provides access to all
which is nesting it and that can access all variables and public and protected methods and
methods defined in the outer class. fields of its super class.
14. Can we execute any code, even before the main method?
Explain?
Yes, We can execute any code, even before the main method. We are
using a static block of code in the class when creating the objects at load
time of class. Any statements within this static block of code will get
executed one time while loading the class, even before the creation of
objects in the main method.
15.
Differentiate between StringBuffer and StringBuilder in
Java programming.
String Buffer String Builder
Storage area is Heap and modified easily. Storage is Heap and can be modified.