Java Interview Prerequisites

Source: Internet
Author: User
Tags connection pooling finally block file transfer protocol multiple inheritance in java log4j java se

1. What is the B/s structure? What is the C/s architecture
    1. b/S (browser/server), browser/server program
    2. c/S (client/server), client/server, desktop applications

      2. What do you know about network protocols?

      HTTP: Hypertext Transfer Protocol
      FTP: File Transfer Protocol
      SMPT: Simple Mail protocol
      TELNET: Remote terminal protocol
      POP3: Mail Read protocol

What are the development platforms for 3.Java?
JAVA SE:主要用在客户端开发JAVA EE:主要用在web应用程序开发JAVA ME:主要用在嵌入式应用程序开发
4. What is a JVM? What does a Java virtual machine include?

Jvm:java virtual machines, using hardware or software means to implement virtual computers, Java Virtual machines include: registers, stacks, processors

Does 5.Java require developers to recycle memory waste?

Most of the cases are not needed. Java provides a system-level thread to track memory allocations, and memory areas that are no longer used will be automatically recycled

6. What is a JDK? What is a JRE?

Jdk:java Development Kit:java Developer Kit, the environment that developers need to install

Jre:java Runtime Environment:java running environment, Java program needs to install the environment to run

What are the 8.JAVA data structures?
线性表(ArrayList)链表(LinkedList)栈(Stack)队列(Queue)图(Map)树(Tree)
10. What is object-oriented?

All things in the world can be regarded as an object. Each object consists of dynamic behavior and static properties, which constitute an object.

11. What is the relationship between classes and objects?

A class is an abstraction of an object that is a concrete class, a template for an object, an instance of a class.

There are several data types in 12.Java
整形:byte,short,int,long浮点型:float,double字符型:char布尔型:boolean
13. What is implicit conversion and what is an explicit conversion

A display transformation is a type-strong, forcing a large type of data to be assigned to a small type of data; Implicit conversions are a wide range of variables that accept small-scale data; Implicit and explicit conversions are essentially automatic type conversions and forced type conversions.

Can the 14.Char type be converted to int type? Can be converted to a string type, can be converted into a double type

Char is also a special type in Java, its int value starting from 1, a total of 2 16 data; The Char<int<long<float<double;char type can be implicitly converted to the int,double type. But it cannot be implicitly converted to a string, and a strong turn is required if the char type is converted to the Byte,short type.

17. What is included in a Java class?

Properties, methods, inner classes, construction methods, code blocks.

18. For example: if (a+1.0=4.0), so do it?

Not good, because the computer in the floating-point data operation, there will be errors, as far as possible in the Boolean expression does not use floating-point data (If,while,switch to determine the condition does not use floating-point type)

The difference between 20.++i and i++

++i is the first self-increment and then assigns the value

i++ is the first assignment in the self-increment

22. How are there several ways to instantiate an array?

Static instantiation: When an array is created, the elements in the array are specified,

int[] a=new int[]{1,3,3}

Dynamic instantiation: When an array is instantiated, only the extent of the array is specified, and all elements in the array are the default values of the array type

Various data defaults in 23.Java
Byte,short,int,long默认是都是0Boolean默认值是falseChar类型的默认值是‘‘Float与double类型的默认是0.0对象类型的默认值是null
What are the 24.Java popular packages?
Java.langJava.ioJava.sqlJava.utilJava.awtJava.netJava.math
What is the top 25.Java parent class?

Object

What are the common methods of the 26.Object class?
EqualsHashcodetoString
clone
getClass

notify
notifyall
Is there a pointer in 27.java?

There are pointers, but hidden, and developers cannot manipulate pointers directly by the JVM to manipulate pointers

is the value pass reference pass in 28.java?

In theory, Java is a reference pass, and for the base data type, the pass is a copy of the value, not the value itself. For object types, passing is a reference to an object, and when a method operates on an action parameter, the object that the reference is directed to is actually manipulated.

29. Suppose that the variable of an instantiated array is treated as a method parameter, and the elements within the array are changed when the method executes, does the array element change outside the method?

Changed because the pass is a reference to the object, the object to which the reference is directed

30. After instantiating an array, can you change the length of the array?

No, once an array is instantiated, its length is fixed.

32. Participate in the actual parameter

Formal parameters, which are all called "formal arguments," are parameters used when defining method names and method bodies, for receiving the actual values that are passed in when the method is called, and the actual parameters, which are all called "actual arguments," and are the real values that are passed to the method when the method is called.

33. Can the construction method be explicitly called?

You cannot construct a method as a normal method call, but it is called by the system only when the object is created.

34. Can the construction method be rewritten? Can it be overloaded?

Can be overridden, or can be overloaded

35. What is method overloading?

The overload of a method is to allow more than one method of the same name to exist in the same class, as long as they have a different number of arguments or types. In this case, the method is called overloaded, and this process is called the overload of the method (override)

overloaded functions (function overloading): Like function names, parameter lists are different and return types can be the same or not the same. The same classoverride function (function override): function name, argument list, return type are all the same, base class and derived class, implement virtual function 36. What is the difference between an inner class and a static inner class?

The static inner class is independent of the outer class, and the variables, methods in the outer class cannot be accessed directly in the static inner class. If you want to access it, you have to new an object of the external class, using the new object to access it. But can directly access static variables, call static methods;

The ordinary inner class exists as a member of the outer class, and the external class property can be accessed directly in the ordinary inner class, calling the method of the outer class.

If an external class is to access the properties of an inner class or invoke a method of an inner class, you must create an object of an inner class that uses that object to access the property or invoke the method.

If other classes want to access the properties of ordinary inner classes or invoke methods of ordinary inner classes, you must create an object of the ordinary inner class in the outer class as an attribute, and the other class can invoke the method of the ordinary inner class or access the properties of the ordinary inner class through this property

If other classes want to access the properties of a static inner class or invoke a method of a static inner class, create a static inner class object directly.

What is the role of 37.Static keywords?

Static can modify inner classes, methods, variables, code blocks

Static-modified classes are statically internal classes

Static methods are static methods that indicate that the method belongs to the current class, but not to an object , and that it cannot be overridden, and can be invoked directly using the class name. the This or Super keyword cannot be used in the static method .

The static modifier variable is either a statically variable or a class variable, and the static variable is shared by all instances and is not dependent on the object. Static variables have only one copy in memory, and when the JVM loads the class, it allocates only one memory at a time.

Static-decorated blocks of code are called Block blocks, which are usually used for program optimization. Code in a static code block executes only once when the entire class is loaded. Static code blocks can have more than one, and if there are multiple, execute sequentially in order.

Inside C + +, Static is released by the system at the end of the program

The role of 38.Final in Java
Final可以修饰类,修饰方法,修饰变量。修饰的类叫最终类。该类不能被继承。修饰的方法不能被重写。修饰的变量叫常量,常量必须初始化,一旦初始化后,常量的值不能发生改变。
What class is used for manipulating strings in 39.Java?

String,stringbuffer,stringbuilder

What's the difference between 40.stringbuffer,stringbuilder?

Both StringBuffer and StringBuilder inherit the Abstractstringbulder class, and Abtractstringbuilder implements the Charsequence interface, and two classes are used for string manipulation.

The efficiency is higher than string when you modify the delete substitution.

StringBuffer is thread-safe and StringBuilder is non-thread safe. So StringBuilder is more efficient than stringbuffer, and most of StringBuffer's methods are added synchronized keywords.

41.String str= "AAA", like string Str=new string ("AAA")?
不一样的。因为内存分配的方式不一样。第一种,创建的”aaa”是常量,jvm都将其分配在常量池中。第二种创建的是一个对象,jvm将其值分配在堆内存中。
42.String str= "AA", String s= "BB", string aa=aa+s; How many objects have you created?

A total of two references, three objects. Because both "AA" and "BB" are constants, the value of the constant cannot be changed, and when the string concatenation is performed, a new constant is created that is "aabbb" and has to be stored in a constant pool.

43. What are the common methods for the math class in Java?
Pow():幂运算Sqrt():平方根Round(3.45):四舍五入3.5Abs():求绝对值Random():生成一个0-1的随机数,包括0不包括1
ceil(3.45):  向上取整4(ceiling天花板的意思)
floor(3.45): 向下取整(floor地板的意思)
What are the common methods of 44.String classes?
charAt:返回指定索引处的字符indexOf():返回指定字符的索引replace():字符串替换trim():去除字符串两端空白split():分割字符串,返回一个分割后的字符串数组getBytes():返回字符串的byte类型数组length():返回字符串长度toLowerCase():将字符串转成小写字母toUpperCase():将字符串转成大写字符substring():截取字符串format():格式化字符串equals():字符串比较
45. Determine if two objects are the same, can you compare them using Equlas?

No. Equlas are mostly used to make string comparisons, and to determine the basic data type or object type, you need to use = =

What is the difference between 46.== and Equlas?

= = To determine whether the basic data type values are equal, or to determine whether the two objects point to the same memory address, that is to say whether two objects are the same object,Equlas is usually used to do string comparisons.

47. How do I reverse a string?

The reverse method of StringBuilder or StringBuffer

48. What are the characteristics of object-oriented languages?

Encapsulation, inheritance, polymorphism

Whether inheritance in 49.Java is single or multi-inheritance

There are both single and multiple inheritance in Java. There can be only one parent class for Java classes, and for interfaces it is possible to inherit multiple interfaces at the same time

51. Can the construction method be overloaded? Can you rewrite it?

Can be overloaded and must be overridden

52. If the parent class has only a constructor method, does the subclass have to override the constructor of the parent class?

Must override

53. When you create a subclass object, does the parent class construct the method?

will be executed. When you create a subclass object and call the subclass constructor method, the subclass constructor method calls the parent class's constructor by default.

54. What is a parent class reference to a subclass object?

is a special form of representation of Java polymorphism. Create a parent class reference, and let the reference point to the object of a child class

55. When the parent class references a child class object, the subclass overrides the parent class method and property, and when the property is accessed, whose property is accessed? Whose method is called when the method is called?

Subclasses override the parent class methods and properties, access the properties of the parent class, and call the methods of the subclass

What does 56.Super and this mean?
Super表示当前类的父类对象This表示当前类的对象
57. What are the abstract keywords?

Abstract

58. Should abstract classes have abstract methods?

Not necessary. Abstract classes can have no abstract methods.

59. If there is an abstract method in a class, then this must be an abstract class?

Classes that contain abstract methods must be abstract classes

60. Can an abstract class use final decoration?

No. The definition of an abstract class is for others to inherit, and the final decorated class means that the class cannot be inherited, contrary to the idea of an abstract class.

61. What is the difference between an ordinary class and an abstract class?
普通类不能包含抽象方法,抽象类可以包含抽象方法抽象类不能直接实例化,普通类可以直接实例化
62. What is an interface?

An interface is a statement of some function that is provided externally, and is a special Java class

63.JAVA Why do I need an interface?

Interface compensates for the drawbacks of Java single inheritance

64. What are the features of the interface?
接口中声明全是public static final修饰的常量接口中所有方法都是抽象方法接口是没有构造方法的接口也不能直接实例化接口可以多继承
65. What is the difference between an interface and an abstract class?
抽象类有构造方法,接口没有构造方法抽象类只能单继承,接口可以多继承抽象类可以有普通方法,接口中的所有方法都是抽象方法接口的属性都是public static final修饰的,而抽象的不是
What are the two types of anomalies in 66.Java?
编译时异常运行时异常
67. Say a few common compile-timeException Class?
NullPointerException:空指针异常ArrayIndexOutOfBoundsException:数组下标越界NumberFormatException:数字转换异常IllegalArgumentException:参数不匹配异常InstantiationException:对象初始化异常ArithmeticException:算术异常
68. What are the handling mechanisms for exceptions?

Exception catch: Try...catch...finally, Exception thrown: throws.

69. How to customize an exception

Inherit an exception class, usually Rumtimeexception or exception

70. If an exception occurs when an exception is caught, does the return statement outside the try.catch.finally block execute?

Executes, if there is finally, is executed after finally, if no finally is executed after the catch

Does 71.try.catch.finally have to exist?

Try block must exist, catch and finally can not exist, but not at the same time does not exist

74. Does using log4j have any effect on the program?

Yes, log4j is used for logging, logging some key sensitive information, usually logging to a local file or database. Recording in a local file, there are frequent IO operations that can consume some system resources. Logging in the database, the database tables are frequently manipulated, and have a certain impact on system performance. But for program security and data recovery or bug tracking, this resource consumption can be affordable.

How many levels does the 75.log4j log have?

From low to High: Debug, info, warn, error

76. In addition to using new to create objects, what methods can I use to create objects?

Java Reflection

77.Java is it high efficiency to create objects or create objects from new?

Creating objects with new is more efficient. By reflection, find class resources, use the class loader to create, the process is more cumbersome, so less efficient

How many in the 78.Java collection frame?

Coillection, Map.

What are the set frames under the 79.Collection interface?

List: Linear table, set: Unordered collection.

What are the features of the 80.List interface?

Sequential storage, can have duplicate values.

What are the features of the 81.Set interface?

No storage, no duplicate values.

What is the difference between 82.ArrayList and LinkedList?
ArrayList与LinkedList都实现了List接口。ArrayList是线性表,底层是使用数组实现的,它在尾端插入和访问数据时效率较高, Linked是双向链表,他在中间插入或者头部插入时效率较高,在访问数据时效率较低
What's the difference between 83.Array and ArrayList?

Both arrays and ArrayList are collections of data that are used for storage. The ArrayList is implemented using arrays, but the ArrayList array is encapsulated and expanded, with many features that are not available in native arrays. We can understand that ArrayList is an upgraded version of the array.

What are the characteristics of 84.MAP
以键值对存储数据元素存储循序是无须的不允许出现重复键
88. Are you aware of connection pooling and what are the benefits of using connection pooling?

Database connections are very resource-intensive and affect the performance metrics of the program. Connection pooling is used to allocate, manage, and release database connections, allowing applications to reuse the same database connection instead of creating a new database connection each time. Improve program performance by freeing database connections that are idle for long periods of time to avoid connection misses caused by creating too many connections.

What are the two types of IO streams for 90.Java?

According to the function to divide

输入流(input),输出流(output)

According to the type of

字节流,字符流
91. What are the common IO classes?
FileFileInputSteam,FileOutputStreamBufferInputStream,BufferedOutputSreamPrintWriteFileReader,FileWriterBufferReader,BufferedWriterObjectInputStream,ObjectOutputSream
92. The difference between a byte stream and a stream of characters
以字节为单位输入输出数据,字节流按照8位传输以字符为单位输入输出数据,字符流按照16位传输
93.final, Finalize (), finally the nature of different
    1. Final is the key word;
    2. Finalize () as the method;
    3. Finally is the chunk flag, which is used in a try statement;
Role
    1. Final is the keyword used to identify constants, and the final identified keywords are stored in a constant pool (where the concrete usage of final constants is described below);
    2. The Finalize () method is defined in object to be invoked by the JVM when the object "disappears" for garbage collection of objects, similar to a destructor in C + +, which frees up resources used by objects (such as i/0 operations) when the user is customized;
    3. finally{} is used to identify a block of code, with try{}, regardless of whether the code in the try is finished or not executed (meaning there is an exception), the code block of the program will be done;
95. Methods for Thread synchronization

Synchronization method:

Volatile synchronized Reenreantlock lock mechanism communication method:
    1. Wait (): Let the thread wait. Stores a thread in a thread pool.
    2. Notify (): Wakes the waiting thread. The first one in the thread pool is usually awakened. Let the awakened thread be in a temporary blocking state.
    3. Notifyall (): Wakes up all the waiting threads. Wakes all threads in the thread pool.
96. Thread-to-process differences

A process is an independent unit of system resource allocation and scheduling, and threads are the basic unit of CPU dispatch and dispatch.

Relationship of process and thread:

    1. A thread can belong to only one process, while a process may have multiple threads, but at least one thread.
    2. A resource is assigned to a process, and all the threads of the same process share all the resources of that process.
    3. Threads need to be synchronized during execution. Synchronization is achieved between threads of different processes using the means of message communication.
    4. A thread is an execution unit within a process and a scheduler within a process.

The difference between a thread and a process:

    1. Dispatch: A thread acts as the basic unit of dispatch and allocation, and processes as the basic unit of resources.
    2. Concurrency: Not only can concurrent execution between processes, but also concurrent execution between multiple threads of the same process.
    3. Owning a resource: a process is an independent unit that owns resources, and threads do not own system resources, but can access resources that belong to the process.
    4. System overhead: When creating or revoking a process, the system is significantly larger than the cost of creating or revoking a thread, because the system allocates and reclaims resources for it. However, the process has a separate address space, and after the process crashes, it does not affect other processes in protected mode, and the thread is just a different execution path in a process. Thread has its own stack and local variables, but there is no separate address space between the threads, a thread dead is equal to the entire process dead, so the multi-process program is more robust than multithreaded programs, but in the process of switching, the cost of large resources, the efficiency is worse.
99. If the object's reference is set to NULL, will the garbage collector immediately release the memory occupied by the object?

No, in the next garbage collection cycle, this object will be recoverable.

Java Interview Prerequisites

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.