Java Developer written interview 12 questions per day

Source: Internet
Author: User
Tags modifier

1. What is a Java virtual machine? Why is Java called a "platform-agnostic programming language"?
A Java Virtual machine is a virtual machine process that can execute Java bytecode. The Java source file is compiled into a bytecode file that can be executed by the Java virtual machine.
Java is designed to allow applications to run on arbitrary platforms without requiring programmers to rewrite or recompile each platform individually. The Java Virtual machine makes this possible because it knows the instruction length and other features of the underlying hardware platform.
JDK includes runtime Environment (JAVAC) and development environment (JVM)

2. What does method overlay (overriding) and method overloading (overloading) in Java mean?

Method overloads in Java occur when the same class has two or more methods with the same name but different parameters. In contrast, the method overrides the method that the subclass redefined the parent class. Method overrides must have the same method name, parameter list, and return type. Modifiers can only be expanded, and the override may not restrict access to the methods it overrides.


3, Anonymous Inner Class (anonymous inner Class) can extends (inherit) other classes, whether you can implements (implement) interface (interface)?
You can inherit other classes or complete other interfaces, which are common in swing programming.

An anonymous inner class must be constructed with an excuse or an abstract class or an ordinary class, from which the anonymous inner class implements the interface or inherits the class, but cannot inherit the class or implement the interface through extends or implement keywords.

4. Can I inherit the String class?
The string class is the final class and cannot be inherited.

5. Explain the usage of the in-memory stack (stack), heap, and static storage.
Usually we define a variable of a basic data type, a reference to an object, and a field save for a function call to use the in-memory stack space, while the object created by the new keyword and the constructor is placed in the heap space, and the literal in the program (literal) is written as 100, "Hello" And constants are placed in a static storage area. Stack space operation is the fastest but also very small, usually a large number of objects are placed in the heap space, the entire memory, including the hard disk of virtual memory can be used as heap space.
String str = new string ("Hello");
In the above statement, STR is placed on the stack, the string object created with new is placed on the heap, and the literal "hello" is placed in the static storage area.
Supplement: A technique called escape analysis is used in newer versions of Java to put some local objects on the stack to improve the operational performance of the object.

6. What are the uses of the final keyword in Java?
(1) Modifier class: Indicates that the class cannot be inherited, (2) The Modification method: Indicates that the method cannot be overridden, (3) A modifier variable: Indicates that the value cannot be modified (constant) after the variable can be assigned only once.

7. What is the difference between super () and this ()?
This (): the object of the current class, Super Parent class object.
Super (): Access to the members and behavior of the parent class in the subclass must be constrained by the class inheritance rule
And this he represents the current object, of course all resources can be accessed.
In the constructor, if the first row is not written super (), the compiler inserts it automatically. But if the parent does not have a constructor with no arguments, or if the function is privatized (with private adornments). You must now add an instantiation construct to the parent class. And this does not have this requirement, Because of its own instantiation of the construction.
The method used by super and this is pretty much the same. It's just super. Consider whether you can access the resources of its parent class.

8. Can we declare that the main () method is non-static?
No, the main () method must be declared static so that the JVM can call the main () method without instantiating its class.
If you remove the "static" declaration from the main () method, the compilation can still succeed, but will cause the program to fail at run time.

9. What are internal and external connections?
Inner joins: An inner join is a join that compares the values of the columns to be joined by comparison operators.
Outer joins: include a LEFT outer join, a right outer join, or a full outer join.
(1) left-side connection: either outer join
The result set of the left outer join includes all rows of the left table specified in the OUTER clause, not just the rows that match the joined columns. If a row in the left table does not have a matching row in the right table,
All select list columns in the right table in the associated result set row are null (NULL).
(2) Right Join
A right outer join is a reverse join of a left outer join. All rows of the right table will be returned. If a row in the right table does not have a matching row in the left table, a null value will be returned for left table.
(3) Complete outer join: Full JOIN or fully outer join
A full outer join returns all rows from the left and right tables. When a row does not have a matching row in another table, the selection list column for the other table contains a null value. If there are matching rows between the tables, the entire result set row contains the data values of the base table.

10. Briefly describe the meaning of the view
The meaning of a view lies in two ways:
1) simplify complex queries. If you need to perform a complex query frequently, you can build a view based on this complex query, and then query this view.
2) Restrict data access. A view is essentially a SELECT statement, so when you access the view, you can only access the columns that are involved in the corresponding SELECT statement, and the other columns in the Base table act as security and secrecy.

11. What are the transactions in the database?
A transaction (transaction) is an ordered set of database operations as a unit. If all operations in the group are successful, the transaction is considered successful and the transaction is unsuccessful even if only one operation fails. If all operations are completed,
The transaction is committed and its modifications are made to all other database processes. If an operation fails, the transaction is rolled back, and the effect of the firm's operations is canceled.

12. What is the function of the display attribute?
You can use the Display property to define the type of box that the element generates when the layout is established.
1) If you set the Display property to block, you can make inline elements (such as <a> elements) behave like block-level elements;
2) If you set the display property to inline, you can make the block-level elements (such as the <p> element) behave like inline elements;
3) You can set the display property to none so that the generated element does not have a box at all. In this case, the box and all its contents are no longer displayed and do not occupy space in the document.

Java Developer written interview 12 questions per day

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.