Interview questions about basic Java knowledge

Source: Internet
Author: User
Tags bit set

Java Programmer's interview will inevitably encounter some basic problems, but do not underestimate these basic things, often here can reflect a programmer's familiarity with the programming language.

650) this.width=650; "src=" Http://183.61.143.148/group1/M00/02/3A/tz2PlFQzhVfwBkmlAAGHEhFA2IA630.png "/>

1. Can I include more than one non-inner class in a ". Java" source file? If yes, what are the restrictions?

you can. These classes can have at most one public, and if there is a public class, the source file name must be the same as the name of the class.
2, write a simple program, print out "Hello world! "
Class helloworld{
Public static void Main (string[] args) {
System.out.println ("Hello world!");
}
}
3, briefly describe what GC is, why use GC in Java?
GC is the meaning of garbage collection (garbage Collection), memory processing is where programmers are prone to problems, forgetting or wrong memory recycling can cause program or system instability or even crashes, The GC functionality provided by Java can automatically monitor whether an object exceeds the scope to achieve the purpose of automatically reclaiming memory, and the Java language does not provide a way to release the displayed operation of the allocated memory.
4. Is there a goto in the Java language?
there is a. Goto exists as a reserved word in Java. For a detailed discussion of Goto, see the "About goto statement. txt" file。
5. Please answer the merits and principles of garbage collection, and briefly describe 2 kinds of recycling mechanism.
garbage collection can improve programmer's programming efficiency, so that programmers can no longer need to consider memory management, but focus on program writing, effectively prevent memory leaks and improve the efficiency of memory utilization.
The garbage collector is usually run as a separate low-level thread, and in unpredictable cases the dead or unused objects in the heap are purged and reclaimed, and we cannot call the garbage collector in real time to garbage collection of specific objects or all objects. However, we can call the object's System.GC () method to proactively notify the virtual machine for garbage collection, and obviously there is no guarantee that the GC will execute. The recycling mechanism has generational replication garbage collection and token garbage collection, incremental garbage collection.
6. Describe the principle mechanism of the JVM loading class file?
The JVM loads the class file to read the class file from the hard disk to the memory. Typically, a class file is read only once.
7. Can the garbage collector reclaim memory immediately? What is the way to proactively notify a virtual machine for garbage collection?
System.GC () can proactively notify a virtual machine for garbage collection But the Java language specification does not guarantee that the GC will execute, because the garbage collector's thread priority is low.
8, please list some of the commonly used classes, packages, interfaces (at least 5 of the list)?
1). Package:
1>.java.lang Package: Java's core class library, contains the necessary system classes to run Java programs, such as basic data types, basic math functions, string processing, threading, exception handling classes, the system default load this package
2>. java.util Package: Java Utility Class Library Java.util package. In this package, Java provides some useful methods and data structures. For example, Java provides a date (Data) class, a calendar class to produce and get dates and times, a random number class that produces random numbers of various types, and a stack (stack), vector, bit set (Bitset), and a hash table (Hashtable) class to represent the corresponding data structure.
3>. java.io Package: The Java language's standard input/output class library, such as basic input/output streams, file input/output, filter input/output streams, and more.
4>. Java.lang.reflect Package: Provides tools for reflecting objects.
5> Java.util.zip Package: Implementing file Compression
2) Class:
1> Java.lang.Object
2> java.lang.String
3> Java.lang.System
4> Java.io.File
5> Java.io.FileInputStream
3). Interface:
1>. Java.util.List
2> Java.util.Map
3>.java.util.iterator
4>.java.sql.callablestatement

5>.java.lang.comparable

there's more . Programming Language Tutorials knowledge can be landed on E mentor Network.

Interview questions about basic Java knowledge

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.