目录
选择题
- Statement用于在已经建立的连接的基础上向数据库发送SQL语句的对象。它只是一个接口的定义,其中包括了执行SQL语句和获取返回结果的方法。实际上有3种 Statement 对象:Statement、PreparedStatement(继承自Statement )和 CallableStatement(继承自PreparedStatement)。
- 它们都作为在给定连接上执行 SQL 语句的容器,每个都专用于发送特定类型的 SQL 语句: Statement 对象用于执行不带参数的简单 SQL 语句;PreparedStatement 对象用于执行带或不带 IN 参数的预编译 SQL 语句;CallableStatement 对象用于执行对数据库已存储过程的调用。
![]()
- LinkList是实现了List,List是一个接口
- Set也是一个接口,肯定是实现
- WeakMap不存在于java集合框架的。只有一个叫做WeakHashMap(继承AbstractMap)
编程题
![]()
import java.util.*; public class LCA { public int getLCA(int a, int b) { // write code here while(a!=b){ if(a>b){ a/=2; }else{ b/=2; } } return a; } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int max=0; int count=0; while(n>0){ if((1&n)==1){ count++; if(count>max){ max=count; } }else{ count=0; } n=n>>1; } System.out.println(max); } }