Java basic question 10 Road 2

Source: Internet
Author: User

1 What is the difference between collection and collections?

Java.util.Collection is a collection interface. It provides a common interface method for basic manipulation of collection objects.

The collection interface has many specific implementations in the Java class Library.

The meaning of the collection interface is to provide a maximum unified operation for a variety of specific collections.

Java.util.Collections is a wrapper class. It contains a variety of static polymorphic methods related to set operations.

This class cannot be instantiated, just like a tool class that serves the Java collection framework.

Package Uue;import java.util.ArrayList;  Import java.util.Collections;  Import java.util.List;    public class Testcollections {public            static void Main (String args[]) {                 list<double> List = new Arraylist< ;D ouble> (); Note that list is a double array[that implements the collection interface          ] = {111, 456, 231};                  for (int i = 0; i < Array.Length; i++) {              list.add (new Double (Array[i]));          }                                  Collections.sort (list);                                  for (int i = 0; i < Array.Length; i++) {              System.out.println (List.get (i));          }          Result: 23.0 111.0 112.0 231.0 456.0      }  }  

  

2 The difference between overload and override?

Overload

Overloading is a representation of polymorphism in a class.

It means that a class can have the same function name, but the parameter name, return value, the type is not the same as several functions;

Override

When a subclass inherits a parent class, you can define a method with the same name and argument as its parent class.

When a subclass calls this function, the subclass's method is called automatically, and the parent class is overwritten (overridden).

Overrides and overloads of a method are different manifestations of Java polymorphism.

3 common types of runtimeexception?

NullPointerException-NULL pointer reference exception
ClassCastException-type cast exception.
IllegalArgumentException-Pass an illegal parameter exception.


ArithmeticException-Arithmetic Operation exception
Arraystoreexception-Storing an incompatible object exception with the declaration type in the array


Indexoutofboundsexception-Subscript out-of-bounds exception
Negativearraysizeexception-Create an array error exception with a negative size


NumberFormatException-Numeric Format exception
SecurityException-Security exception
Unsupportedoperationexception-Unsupported Operation exception

4 JSP built-in objects?

Nine built-in objects
PageContextjavax.servlet.jsp.PageContext
Requestjavax.servlet.http.HttpServletRequest
Responsejavax.servlet.http.HttpServletResponse


Sessionjavax.servlet.http.HttpSession
Applicationjavax.servlet.Servlet context–> available this.getservletcontext () override


Configjavax.servlet.ServletConfig
Outjavax.servlet.jsp.JspWriter

Exceptionjava.lang.Throwable
Pagejava.lang.Object

b) Role:
1, PageContext means the page container –>el, label, upload
2. Request server-side access to client information: header information, cookies, request parameters, MVC design mode
3. Response server-side response to client information: cookies, redirects
4, session represents each user, for login verification on
5, application represents the entire server, Getrealpath ()
6, config to initialize the parameters, initialization parameters in Web. config
7, exception represents the error page of the processing operation
8, page as this, representing the entire JSP page
9, out output, but use expression output as much as possible

5 Are there several types of streams in Java?

6 A simple understanding of the IOC?

Java basic question 10 Road 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.