赞
踩
1. String #name = "Jane Doe";
2. int $age=24;
3. Double _height = 123.5;
4. double ~temp = 37.5;
A. 1,2.
B. 2,3.
C. 3,4.
D. 1,4.
Integer b = 200;
Integer a = 200;
int c = 200;
System.out.println(a.equals(b));
System.out.println(a == c);
A.fasle;true
B.false;false
C.true;fasle
D.true;true
public class Test03 {
private int x = 100;
public static void main(String[] args) {
int x =5;
boolean b1 = true;
boolean b2 = false;
if((x==4) && !b2)
System.out.print("l");
System.out.print("2");
if ((b2 = true) && b1)
System.out.print("3");
}//23
}
A.123
B.23
C.3
D.2
public class Test04 {
public static void main(String[] args) {
int x=0;
int y=10;
do {
y--;
if(y==6)continue;
++x;
} while (x < 5);
System.out.print(x + "," + y);
}
}
A.5,4
B.4,5
C.5,6
D.6,6
1.int[] a={1,2,3};
2.int[] b=new int[5];
3.int[][] c={{1},{2}};
4.int[][]d =new int[5][];
A.1,2,3,4都正确
B.只有1,2正确
C.只有1正确
D.只有1,3正确
public class Test06 {
static void f1(int...x) {
System.out.println("x.length="+x.length);
}
static void f1(int y){
System.out.println("y="+y);
}
public static void main(String[] args) {
f1(10);
}
}
A.编译错误
B.输出y=10
C.输出x.length=1
D.输出y=10;x.length=1
7.阅读如下代码,其运行结果正确的是?()
public class Test07 {
public static void main(String[] args) {
int a=10;
int b[]={20};
change(a,b);
System.out.println(a+","+b[0]);
}
static void change(int a,int[] b){
a=11;
b[0]=21;
}
}
A.10,20
B.11,21
C.11,20
D.10,21
public class Test08 {
static void foo(int...x){
//code(插入代码处)
}
}
A. foreach(x) System.out.println(z);
B. for(int z : x) System.out.println(z);
C. while( x.hasNext()) System.out.println( x.next());
D. for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
public class Test09 {
public static void main(String[] args) {
String o = "";
z :
for(int x=0; x<3; x++){
for(int y=0; y<2; y++){
if(x == 1) break;
if(x==2 && y==1) break z;
o = o + x + y;
}
}
System.out.println(o);
}
}
A. 编译失败
B. 0001
C. 000120
D. 00012021
public class Test10 {
static void f1(){
throw new RuntimeException();
}
static void f2(){
f1();
throw new Exception();
}
public static void main(String[] args) {
f2();
}
}
A. 程序会抛出RuntimeException
B. 程序会抛出Exception
C. 程序会抛出RuntimeException,Exception
D. 编译失败
public class Test11 {
static void test() throws RuntimeException{
try{
System.out.print("test");
throw new RuntimeException();
}catch(Exception e){
System.out.print("exception");
}
}
public static void main(String[] args){
try{test();}
catch(RuntimeException ex){
System.out.print("runtime");
}
System.out.print("end");
}
}
A. test end
B. 编译失败
C. test runtime end
D. test exception end
public class Test12 {
private static Integer b;
public static void main(String[] args){
int a = 10;
print(a);
print(b);
b = a;
print(b);
}
private static void print(Integer value){
int add = value+5;
System.out.println(add);
}
}
A. 15,5,20
B. 编译失败
C. 15,5,15
D. 运行时出现NullPointerException
class A{
int a=10;
public A(int a){
this.a=a;
}
}
class B extends A{
int a;
public B(int a){
this.a=a;
}
}
public class Test13 {
public static void main(String[] args) {
A a=new B(20);
System.out.println(a.a);
}
}
A. 10
B. 20
C. 编译失败
D. 0
interface IC{
int M = 10;
}
class C implements IC{
int M = 20;
int N = 30;
}
public class Test14{
public static void main(String[] args) {
IC c1=new C();
System.out.println(c1 instanceof C);
System.out.println(c1.M);
System.out.println(c1.N);
}
}
A. true,10,30
B. false,10,30
C. true,20,30
D. 编译失败
public class Test15 {
public static void main(String args[]) {
Thread t = new Thread() {
public void run() {
pong();
}
};
t.run();
System.out.print("ping");
}
static void pong() {
System.out.print("pong");
}
}
A. pingpong
B. pongping
C. pingpong和pongping都有可能
D. 编译错误
A. NullPointerException
B. ClassCastException
C. FileNotFoundException
D. IndexOutOfBoundsException
package com.cy.test;
import java.util.ArrayList;
import java.util.List;
public class Test16 {
static void print(List<Object> list){
System.out.println(list);
}
public static void main(String[] args) {
List<Integer> list2=new ArrayList<>();
list2.add(100);
list2.add(100);
print(list2);
}
}
A. [100]
B. [100,100]
C. 输出list对象地址
D. 编译错误
package com.cy.test;
enum Gender{
MALE,FEMALE,NONE;
public Gender(){}
public static void value(Gender gender){
switch (gender){
case MALE: System.out.println("男士");break;
case FEMALE: System.out.println("女士");break;
default: System.out.println("未知");
}
}
}
public class Test17 {
public static void main(String[] args) {
Gender.value(Gender.MALE);
}
}
A. 男士
B. 女士
C. 未知
D. 编译错误
package com.cy.test;
@Target(ElementType.TYPE)
@interface Entity{
String value();
}
@Entity(value="obj")
class Obj{}
public class Test18 {
public static void main(String[] args) {
Entity entity=Obj.class.getAnnotation(Entity.class);
System.out.println(entity.value());
}
}
A. obj
B. 编译错误
C. 运行时会出现空指针异常
D. null
package com.cy.test;
import java.util.LinkedHashMap;
public class Test19{
public static void main(String[] args) {
LinkedHashMap<String,Object> map=
new LinkedHashMap<>(3,0.75f,true);
map.put("A", 100);
map.put("B", 200);
map.get("A");
map.put("C", 300);
map.put("D", 400);
map.get("B");
System.out.println(map);
}
}
A. {A=100, B=200, C=300, D=400}
B. {A=100, C=300, D=400, B=200}
C. {B=200, A=100, D=400, C=300}
D. 不确定
21.对如下代码描述错误的是?()
@FunctionalInterface
interface IA{
void show();
}
A. @FunctionalInterface 描述的是JDK8推出的函数式接口。
B. @FunctionalInterface 描述的接口中只能有一个抽象方法
C. @FunctionalInterface 描述的接口中可以有多个抽象方法
D. @FunctionalInterface 描述的接口中允许有静态方法。
package com.cy.test;
import java.util.Arrays;
import java.util.List;
public class Test21 {
public static void main(String[] args) {
List<String> list=Arrays.asList( "B", "A", "C" );
list.sort((String e1,String e2) -> {
int result = e1.compareTo( e2 );
return result;
} );
list.add("D");
System.out.println(list);
}
}
A. 程序在JDK8环境下可以正确编译。
B. 程序的输出结果是[A,B,C,D]
C. 程序中e1,e2两个变量左侧的String类型可以省略。
D. 输出list时,默认底层会调用list变量指向的对象的toString()方法
package com.cy.test;
import java.util.Arrays;
import java.util.List;
public class Test22 {
public static void main(String[] args) {
List<Integer> list = Arrays.asList(3, 2, 12, 5, 6, 11, 13);
long count = list.stream()
.filter(i -> i % 2 == 0||i % 3 == 0)
.count();
System.out.println(count);
}
}
A. JDK8环境下编译失败。
B. 输出的结果为 6
C. 输出的结果为 4
D. 输出的结果为 3
package com.cy.test;
interface IM{
default void f1(){
System.out.println("f1()");
}
static void f2() {
System.out.println("f2()");
}
}
class ClassM implements IM{
public void f1(){
System.out.println("ClassM.f1()");
}
static void f2() {
System.out.println("ClassM.f2()");
}
}
public class Test23 {
public static void main(String[] args) {
IM m1=new ClassM();
m1.f1();
m1.f2();
}
}
A.f1() f2()
B.ClassM.f1() ClassM.f2()
C.ClassM.f1() f2()
D.编译失败
A. 将将Java中的Date日期对象转换为字符串
B. 可以将日期格式字符串转换为Java中的Date日期对象。
C. JDK8中可使用DateTimeFormatter对象替换SimpleDateFormat对象。
D. 允许多线程共享使用。
select distinct id,name,age from A join B join C on A.xx=B.xx and B.xx=C.xx where xx=? and xx=? group by xx having xx=? order by xx desc/asc limit m,n
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。