"Big Data-Phase II" Java Foundation fifth day job

Source: Internet
Author: User

1. Text describes the role of static code blocks.
Static code blocks are executed one time by default when the class is loaded, and only once.

2. What is the order in which the code blocks and constructors are called? and the declaration location of the method has
Off Why? What is the purpose of building blocks of code?

Constructs a block of code that takes precedence over a call to a constructor.
is independent of the location of the method declaration, because constructing a block of code will be adjusted by default each time the object is created

Use it once.
The purpose of constructing a code block is to initialize the member variable.

3. Will the static code block be executed when the class loads? How do I manually control class loading?
Static code blocks are bound to be loaded.
Manually control class loading using Class.forName ("classname"), when the class is loaded by default,
Executes a code block.

4. Define the class Person,man,woman to form an inheritance relationship.

Class Person{}class man extends Person{}class Woman extends person{}


5. What is an abstract method? What is an abstract class? If the abstract class has constructors, can
be overloaded?
Abstract method: The method without the {} method body is an abstract method that needs to be modified with an abstract.     

  Abstract methods must be overridden.
Abstract Classes: Classes that have abstract methods must be abstract classes, and abstract classes can have no abstract methods

. Abstract classes also need to use an abstract modifier. Abstract classes must be inherited.



6. What are the illegal combinations of abstract modifiers? and give a reasonable explanation?
abstract + static static modifier makes it easier to access public properties, abstract

The direct access to the

Abstract + final decoration is final, cannot be changed, abstract needs to go to the instance

, need to operate

Abstract + private Private is not allowed to inherit from the quilt class, and abstract classes must be

to be instantiated by the subclasses.


7.super and this role as well as usage and considerations?

    public static void main (String[] args) {         IWRB WOMANSTAR = NEW IWRB () {                          Public void white ()  {                 system.out.println ();             }            public void  Rich ()  {            }             public void beauti ()  {             }        };       &nbSp; richman man = new richman ();         Man.marry (Womanstar);            }}interface  Iwhite{    public void white ();} Interface irich{    public void rich ();} Interface ibeauti{    public void beauti ();} interface iwrb extends iwhite, irich , ibeauti{}class richman{     public void marry (Iwrb woman) {         System.out.println ("Find love");     }


This article is from the "Fan Penguin" blog, please be sure to keep this source http://xpenguin.blog.51cto.com/4912157/1771330

"Big Data-Phase II" Java Foundation fifth day job

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.