1. What are java beans?
JavaBeans is a portable, platform-independent component model written in the Java programming language, developed in collaboration with industry leaders. It enables developers to write reusable components once and run them anywhere -- benefiting from the platform-independent power of Java technology. JavaBeans acts as a Bridge between proprietary component models and provides a seamless and powerful means for developers to build components that run in ActiveX container applications.
Java beans is very powerful tool you can use in your servlet/JSP bridge. You can use the servlets to build the bean and can be passed over to the JSP for reading. This provides tight encapsulation of the data while preserving the sanctity of servlets and JSP。
JavaBeans is a portable, platform-independent component model written in the Java programming language, developed in collaboration with industry leaders. It enables developers to write reusable components once and run them anywhere -- benefiting from the platform-independent power of Java technology. JavaBeans acts as a Bridge between proprietary component models and provides a seamless and powerful means for developers to build components that run in ActiveX container applications.
Java beans is very powerful tool you can use in your servlet/JSP bridge. You can use the servlets to build the bean and can be passed over to the JSP for reading. This provides tight encapsulation of the data while preserving the sanctity of servlets and JSP。
2. What is RMI?
RMI stands for Remote Method Invocation. Traditional approaches to executing code on other machines across a network have been confusing as well as tedious and error-prone to implement. The nicest way to think about this problem is that some object happens to live on another machine, and that you can send a message to the remote object and get a result as i
RMI stands for Remote Method Invocation. Traditional approaches to executing code on other machines across a network have been confusing as well as tedious and error-prone to implement. The nicest way to think about this problem is that some object happens to live on another machine, and that you can send a message to the remote object and get a result as i
f the object lived on your local machine. This simplification is exactly what Java Remote Method Invocation (RMI) allows you to do.
3. How does Java inheritance work?
A class can only directly extend one class at a time. Multiple inheritance is only allowed with regard to interfaces. A class can implement many interfaces. But a class can only extend one non-interface class.
A class can only directly extend one class at a time. Multiple inheritance is only allowed with regard to interfaces. A class can implement many interfaces. But a class can only extend one non-interface class.
4. How does exception handling work in Java?
1.It separates the working/functional code from the error-handling code by way of try-catch clauses.
2.It allows a clean path for error propagation. If the called method encounters a situation it can't manage, it can throw an
exception and let the calling method deal with it.
exception and let the calling method deal with it.
3.By enlisting the compiler to ensure that "exceptional" situations are anticipated and accou
nted for, it enforces powerful coding.
4.Exceptions are of two types: Compiler-enforced exceptions, or checked exceptions and Runtime exceptions, or unchecked exceptions. Compiler-enforced (checked) exceptions are instances of the Exception class or one of its subclasses -- excluding the RuntimeException branch. The compiler expects all checked exceptions to be appropriately handled. Checked exceptions must be declared in the throws clause of the method throwing them -- assuming, of course, they're not being caught within that same method. The calling method must take care of these exceptions by either catching or declaring them in its throws clause. Thus, making an exception checked forces us to pay heed to the possibility of it being thrown. An example of a checked exception is java.io.IOException. As the name suggests, it throws whenever an input/output operation is abnormally terminated.
5. Does Java have destructors?
Java does not have destructors. Garbage collector does this job periodically depending upon the memory requirements of the machine and on the fact that a particular object is no
Java does not have destructors. Garbage collector does this job periodically depending upon the memory requirements of the machine and on the fact that a particular object is no
longer needed.
But it has finalizers that does a similar job. The syntax is
public void finalize() { }
If an object has a finalizer, the method is invoked before the system garbage collects the object, but using finalize() does not guarantee that it would be called b4 garbage collector is invoked.
But it has finalizers that does a similar job. The syntax is
public void finalize() { }
If an object has a finalizer, the method is invoked before the system garbage collects the object, but using finalize() does not guarantee that it would be called b4 garbage collector is invoked.
6. What does the "final" keyword mean in front of a variable? A method? A class?
A final variable cannot be reassigned, but it is not constant. For instance,
final StringBuffer x = new StringBuffer();
x.append("hello");
A final variable cannot be reassigned, but it is not constant. For instance,
final StringBuffer x = new StringBuffer();
x.append("hello");
is valid. X cannot have a new value in it, but nothing stops operations on the object that it refers, including destructive operations.
Also, a final method cannot be overridden or hidden by new access specifications. This means that the compiler can choose to in-line the invocation of such a method. (I don't kno
Also, a final method cannot be overridden or hidden by new access specifications. This means that the compiler can choose to in-line the invocation of such a method. (I don't kno
w if any compiler actually does this, but it's true in theory.)
The best example of a final class is String, which defines a class that cannot be derived.
The best example of a final class is String, which defines a class that cannot be derived.
6. Access specifiers: "public", "protected", "private", nothing?
Public? Any other class from any package can instantiate and execute the classes and methods
Protected? Only subclasses and classes inside of the package can access the classes and methods
Private? The original class is the only class allowed to execute the methods.
And in case if there is no modifier specified, it means, only the classes inside the package can access this class and its methods, it is also called "Friendly".
Public? Any other class from any package can instantiate and execute the classes and methods
Protected? Only subclasses and classes inside of the package can access the classes and methods
Private? The original class is the only class allowed to execute the methods.
And in case if there is no modifier specified, it means, only the classes inside the package can access this class and its methods, it is also called "Friendly".
Question:What is the difference between an Interface and an Abstract class?
Question: What is the purpose of garbage collection in Java, and when is it used?
Question: Describe synchronization in respect to multithreading.
1.what is single inheritance.
-a-Z}y^a#K+@M JAVA中文站社区门户g}F3@&Qans:one class is inherited by only other one class
9.what is interface.
3qePl` JAVA中文站社区门户 {._ x:k{ans:Interface has only method declarations but no definition
10.what is differenec between abstract class and interface.JAVA中文站社区门户/O j'KX+w"XI j3FN.j
JAVA中文站社区门户9s"A@:C;_ ans:In abstract class some methods may contain definition,but in interface every method should be abstract
/h-H8k!?2W |J JAVA中文站社区门户yL yO
O _ r-K7s9fo(c11.how to u prove that abstrace class cannot instantiate directly.JAVA中文站社区门户rMn?3u'R ytn1K
O _ r-K7s9fo(c11.how to u prove that abstrace class cannot instantiate directly.JAVA中文站社区门户rMn?3u'R ytn1K
JAVA中文站社区门户9r`4R4Wr"J ans:As they dont have constructor they cant be instantiated
}${^ {@E6` JAVA中文站社区门户O7v0x*kP12.what is differenece between string and stringbuffer.
+O N)LrH JAVA中文站社区门户n:R] W7
ans:Strings are immutable where as string buffer can be modifiedJAVA中文站社区门户#c5e3sR_&r I8s H p
springboor面试题2{U-\ F D1Gs13.what is immutableJAVA中文站社区门户8e T#?cnE+\vUC
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论