Niu Ke's Diary of Writing Questions (2021-12-14)

Niu Ke's Diary of Writing Questions (2021-12-14)

topic:

建立Statement对象的作用是?

连接数据库
声明数据库
执行SQL语句
保存查询结果

Parse:

Correct Answer: C

Class.forName("com.mysql.jdbc.Driver"); //Load jdbc driver
con=DriverManager.getConnection(url,user,password); //Create a connection
stmt=con.createStatement(); //Create statement execution (stateMent is used to execute simple sql statements without parameters,
PreparedStatement is used to execute precompiled sql statements with parameters to prevent sql injection, and CallableStatement provides a standard way to call stored procedures)
stmt.execute("sql Statement");
rs=stmt.executeQuery("sql query statement"); //result set


topic:

下面有关maven和ant的描述,描述错误的是?

Ant 没有正式的约定如一个一般项目的目录结构,你必须明确的告诉 Ant 哪里去找源代码
Maven 拥有约定,因为你遵循了约定,它已经知道你的源代码在哪里
maven和ant都有“生命周期”的概念,当你输入一个命令后,maven或者ant会执行一系列的有序的步骤,直到到达你指定的生命周期
Ant构建文件默认命名为build.xml,Maven默认构建文件为pom.xml

Parse:

Correct Answer: C

Both Ant and Maven are Java-based build tools . In theory, something like make in (Unix) C, but without the flaws of make. Ant is a software build tool, and Maven is positioned as a software project management and understanding tool.
Ant features:
no one agreed upon directory structure › must explicitly tell ant what to do, when to do it, then compile, package › no lifecycle, must define goals and the task sequence they implement › no integrated dependency management
Maven features:
› have conventions , know where your code is and where to put it › have a life cycle, such as executing mvn install to automatically perform compilation, testing, packaging and other build processes › only need to define a pom.xml, and then put the source code in the default Directories, Maven handles other things for you › Has dependency management, repository management


topic:

对于子类的构造函数说明,下列叙述中错误的是( )。

子类不能继承父类的无参构造函数。
子类可以在自己的构造函数中使用super关键字来调用父类的含参数构造函数,但这个调用语句必须是子类构造函数的第一个可执行语句。
在创建子类的对象时,若不含带参构造函数,将先执行父类的无参构造函数,然后再执行自己的无参构造函数。
子类不但可以继承父类的无参构造函数,也可以继承父类的有参构造函数。

Parse:

Correct Answer: D

Constructors cannot be inherited, and constructors can only be called explicitly or implicitly.


topic:

java程序内存泄露的最直接表现是( )

频繁FullGc
jvm崩溃
程序抛内存溢出的Exception
java进程异常消失

Parse:

Correct Answer: C

Java manages memory automatically. Usually, the program runs to a stable state, and the memory size also reaches a basically stable value.
However, memory leaks cause Gc to not be able to recycle the leaked garbage, and the memory continues to grow.
Eventually, the memory limit is exceeded, and OutOfMemoryExpection is thrown.


topic:


下面代码输出结果是?
int i = 5;
int j = 10;
System.out.println(i + ~j);


Compilation error because”~”doesn’t operate on integers
-5
-6
15

Parse:

Correct Answer: C

The formula -n= n+1 can deduce n=-n-1, so ~10=-11 plus 5 results in -6


topic:

下面哪些Java中的流对象是字节流?
FileInputStream
BufferedInputStream
PushbackInputStream
ByteArrayInputStream

Parse:

Correct Answer: ABCD

here is the quote


topic:


jvm中垃圾回收分为scanvenge gc和full GC,其中full GC触发的条件可能有哪些

栈空间满
年轻代空间满
老年代满
持久代满
System.gc()

Parse:

Correct Answer: CDE

Garbage collection mechanism: new generation, old generation, persistent generation
insert image description here
1, new generation :
(1) All objects are created in the Eden area of ​​the new generation. When the Eden area is full, the Minor GC of the new generation is triggered, and the Eden area and the non-idle Survivor area are separated. The surviving objects are copied to another free Survivor area.
(2) To ensure that a Survivor area is empty, the new generation Minor GC is to copy surviving objects between the two Survivor areas until the Survivor area is full.
2. Old age : When the Survivor area is full, objects are copied to the old age through Minor GC. If the old generation is also full, a Full GC will be triggered, and garbage collection will be performed for the entire heap (including the young generation, the old generation, and the persistent generation).
3. Persistent Generation : If the Persistent Generation is full, Full GC will be triggered.


Guess you like

Origin blog.csdn.net/qq_54729417/article/details/121919980