int a = 55; char b = 'e'; system.out.println(a b);
short c = 8; byte d = 16; system.out.println("c | d =" (c | d));
short a = -128; short b = 128; system.out.println("a & b = " (a & b));
char型变量中不能存贮一个中文汉字。
下列哪个选项是合法的标识符?
下列哪个赋值语句是不正确的?
给出下列代码,哪行在编译时可能会有错误? ① public void modify(){ ② int i, j, k; ③ i = 100; ④ while ( i > 0 ){ ⑤ j = i * 2; ⑥ system.out.println (" the value of j is " j ); ⑦ k = k 1; ⑧ } ⑨ }
class count { public int count; public count(int c) { count = c; } public count() { count = 1; } } public class test { public static void increment(count c, int times) { c.count ; times ; } public static void main(string args[]) { count mycount = new count(); int times = 0; for (int i = 0; i < 3; i ) increment(mycount, times); system.out.println("mycount.count=" mycount.count " times=" times); } } 程序的运行结果正确的是()
关于构造方法constructor,下列说确的是()
给出程序的运行结果() class person { string name; int age; person(){ system.out.println("person()"); } void person(){ system.out.println("method()"); } public void tell() { system.out.println("姓名:" name ",年龄:" age); } } public class classtest02 { public static void main(string[] args) { person person = new person(); person.name = "张三"; person.age = 30; person.tell(); } }
以下声明合法的是( )
以下代码运行输出是() class man { private string name = "jack"; int age = 30; } public class mantest { public string tel; public static void main(string[] args) { man m = new man(); system.out.println(m.name); } }
给出以下4个重载的方法show,调用show方法时,下面哪个说法是错误的() (1)show(int a ,int b,int c) (2)show(int a ,int b,double c) (3)show(int a ,double b,double c) (4)show(double a,double b,int c)
java中方法参数的使用情况错误的说法是()
下面的程序中,哪行会报错? public class statictest { int age; string name; static int totalfee = 500; public void showname() { system.out.print(this.name); } public static void showtotalfee() { line 1: system.out.print(totalfee); line 2: showname(); } public static void main(string[] args) { line3: statictest.showtotalfee(); } }
下面程序的运行结果是____ int x=30; int[] numbers=new int[x]; x=60; system.out.println(numbers.length);
数组越界访问会发生什么错误?
关于数组,以下说法错误的是()
string str = new string("hello"); 创建了几个string object?
给出源字符串: string str = "i am a student"; system.out.println(str.substring(7, 14)); system.out.println(str.contains(" student")); 正确的输出结果是哪一项?
public class changestrdemo { public static void changestr(string str){ str="welcome"; } public static void main(string[] args) { string str="home"; changestr(str); system.out.println(str); } }给出程序的运行结果( )
从下面四段代码中选择出正确的代码段()
读代码: 1.package foo; 2.import java.util.vector; 3.private class myvector extends vector { 4.int i = 1; 5.public myvector() { 6.i = 2; 7. } 8.} 9.public class mynewvector extends myvector { 10.public mynewvector () { 11. i = 4; 12.} 13.public static void main (string args []) { 14.myvector v = new mynewvector(); 15. } 16.} 结果是:
父类和子类定义如下: class fatherclass { public fatherclass() { system.out.println("fatherclass create"); } } class childclass extends fatherclass { public childclass() { system.out.println("childclass create"); } public static void main(string[] args) { fatherclass fc = new fatherclass(); childclass cc = new childclass(); } } 请问输出结果为:
构造器constructor是否可被override?
关于抽象类与接口,下列说确的是?
关于实例方法和类方法,以下描述正确的是:( )
error和exception的区别是:
final、finally、finalize的区别有:
关于java异常类型的说法,错误的是:
哪个关键字可以抛出异常?
下列程序的执行,说法错误的是 (c) public class multicatch { public static void main(string args[]) { try { int a=args.length; int b=42/a; int c[]={1}; c[42]=99; system.out.println(“b=” b); } catch(arithmeticexception e) { system.out.println( “除 0 异常: ” e); } catch(arrayindexoutofboundsexception e) { system.out.println( “数组超越边界异常: ” e); } } } a 、程序将输出第 15 行的异常信息 下列程序的执行,说法错误的是: public class multicatch { public static void main(string args[]) { try { int a=args.length; int b=42/a; int c[]={1}; c[42] = 99; system.out.println(“b=” b); } catch(arithmeticexception e) { system.out.println(“除0异常:” e);} catch(arrayindexoutofboundsexception e) { system.out.println(“数组超越边界异常:” e); } } }
对于 catch 子句的排列,下列哪种是正确的 (b ) a 、父类在先,子类在后 b 、子类在先,父类在后 c 、有继承关系的异常不能在同一个 try 程序段内 d 、先有子类,其他如何排列都无关 对于 catch 子句的排列,下列哪种是正确的 (b ) a 、父类在先,子类在后 b 、子类在先,父类在后 c 、有继承关系的异常不能在同一个 try 程序段内 d 、先有子类,其他如何排列都无关 对于catch子句的排列,下列哪种是正确的:
java反射框架主要提供以下功能,哪一个是错误的?
关于java反射机制,下面哪个说法是错误的?
有以下代码: package com; public class test { public static void main(string[] args) { test test = new test(); //here } } 在here处加上以下什么语句,可以获得class对象?(多选)
public class inheritthread extends thread { private string name; public inheritthread (string name) { this.name = name; } public void run() { system.out.println("greetings from thread '" name "'!"); } } public static void main(string args[]) { inheritthread greetings = new inheritthread ("inherited"); greetings.start(); system.out.println(" main thread has been ended"); } 以上代码执行的结果可能是:
线程有 新建( new )、就绪(runnable)、运行(running)、阻塞( blocked )和死亡( dead )5种状态,哪些情况会导致线程进入阻塞状态?
关于线程执行过程说确的是:
当编译并运行下面程序时会发生什么结果() public class bground extends thread{ public static void main(string argv[]){ bground b = new bground(); b.run(); } public void start(){ for (int i = 0; i <10; i ){ system.out.println("value of i = " i); } } }