Java Basic problem Set

Source: Internet
Author: User

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 its characteristics of the underlying hardware platform.

What is the difference between 2.JDK and JRE?

The Jre:java runtime environment, which includes Java virtual machines. Java Core class libraries and support files, which do not include development tools (JDK)-compilers, debuggers, and other tools.

The Jdk:java Development Kit, which is a complete Java software development package, contains the JRE, compilers, and other tools (such as the Javadoc,java Debugger), which allows developers to develop, compile, and execute Java applications.

3. "Static" keyword is wonder why meaning? Is it possible to overwrite (override) a private or static method in Java?

The "static" keyword indicates that a member variable or a member method can be accessed without an instance variable of the class to which it belongs.

The static method in Java cannot be overwritten because the method overrides are dynamically bound based on the runtime, and the static method is statically bound at compile time. The static method is not relevant to any instances of the class, so it is conceptually not applicable.

Private methods cannot be overridden in Java, because variables and methods that are modified by private are only available in the current class, and if other classes inherit the current class, they cannot be accessed by private variables or methods, and of course cannot be overwritten.

4. Can I access non-static variables in the static environment?

The static variable belongs to the class in Java, and it has the same value in all instances. Static variables are initialized when the class is airborne into Java virtual. If your code tries to access a non-static variable without an instance, the compiler will give an error because the variables have not been created yet and are not associated with any instances.

What are the data types supported by 5.java? What is auto-unboxing?

(1) Byte

(2) Short

(3) INT

(4) long

(5) Float

(6) Double

(7) Boolean

(8) Char a conversion of the Java compiler between the base data type and the corresponding object wrapper type when boxed automatically. For example: the conversion of int into integer,double into double ..., the reverse is automatic unpacking.

What does the method overlay (overriding) and method overloading (overloading) in 6.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. The override may not restrict access to the methods it covers.

In 7.java, what is a construction method? What is a constructor method overload? What is a copy construction method?

The construction method is called when the new object is created. Each class has a method of construction. The Java compiler creates a default constructor for this class in cases where the programmer does not give the Class A constructor method.
Construction method overloading and method overloading are similar in Java. You can create multiple construction methods for a class. Each construction method must have its own unique argument list.
Java does not support copy construction methods like in C + +, because Java does not create a default copy construction method if you do not write your own construction method.
Does 8.java support multiple inheritance?

Classes in Java do not support multiple inheritance, only single inheritance (that is, a class has only one parent). However, the interface in Java supports multiple inheritance, that is, a sub-interface can have multiple parent interfaces. (The function of the interface is to extend the function of the object, a sub-interface inherits multiple parent interfaces, indicating that the sub-interface extends several functions, when the class implements the interface, the class expands the corresponding function).

9. What is the difference between an interface and an abstract class?

Java provides and supports the creation of abstract classes and interfaces. Their implementations have something in common, except that all the methods in the interface are implicitly abstract. Abstract classes can contain both abstract and non-abstract methods.

A class can implement many interfaces, but it can only inherit an abstract class class that does not implement all of the methods of an abstract class and an interface declaration, and of course, in this case, the class must be declared abstract.

An abstract class can implement an interface without providing an interface method implementation. The variables declared in the Java interface are final by default. An abstract class can contain non-final variables.

The member functions in the Java interface are public by default. The member functions of an abstract class can be private,protected or public. An interface is absolutely abstract and cannot be instantiated. An abstract class can also not be instantiated, but it can be called if it contains the main method.

10. What is value delivery and app delivery?

A value pass is a basic variable, passing a copy of the variable, changing the copy without affecting the original variable.

A reference pass is generally for an object type variable, passing a copy of the object's address, not the original object itself.
It is generally assumed that delivery within Java is a value pass. The delivery of an instance object in Java is a reference pass

  

  

Java Basic problem Set

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.