以下代码的编译运行结果为()。 public class Test { public static void main(String args [ ]){ int age; age = age + 1; System.out.println("The age is " + age); } }A.编译通过,运行无输出B.编译通过,运行输出:The age is 1C.编译通过,但运行时出错D.不能通过编译
以下代码的编译运行结果为()。 public class Test { public static void main(String args [ ]){ int age; age = age + 1; System.out.println("The age is " + age); } }
A.编译通过,运行无输出
B.编译通过,运行输出:The age is 1
C.编译通过,但运行时出错
D.不能通过编译
参考答案和解析
不能通过编译
相关考题:
下列程序的运行结果是【 】。public class Test {public static void main (String args[]) {String s1="hello!";System.out.println (s1.toUpperCase());}}
本题中定义了一个带有参数的构造方法javal,并定义了一个该类的对象temp。构造方法javal有两个参数:字符串name和整型age。定义对象temp时将字符串“Tom"和整数17传递给构造方法,构造方法将这两个参数打印输出。 public class javal{ String name; int age; public static void main(String[]args){ String name="Tom"; int age=17; javal temp = ; } public javal(String name, ){ ; this.age= age; System.out.println(name+"is"+age+" years old."); } }
下列代码的运行结果是( )。 public class Test { public static void main(String args[]) { System.out.println(89>>1); } }A.44B.45C.88D.90
阅读下列代码 public class Test{ public static void main(String args[]){ System.out.println(89>>1); } } 其运行结果是A.44B.45C.88D.90
class Person{ String name,department; int age; public Person(Stringn){name=n;} public Person(String n, int a){name=n;age=a;} publicPerson(String n,String d,int a){ doing the same as two argumentsversion of constructer including assignment name=n,age=a } } 下列哪一个选项可以添加到“doing the same....”处?()APerson(n,a)Bthis(Person(n,a))Cthis(n,a)Dthis(name,age
给出下列的不完整的类代码,则哪个语句可以被加到横线处? ( ) class Person{ String name,department; int age; public Person(String n){name=n;} public Person(String n,int s){name=n; age=a;} public Person(String n,String d,int a){ department=d;______ } }A.Person(n,a);B.this(Person(n,a));C.this(n,s);D.this(name,age);
下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }A.编译错误B.0C.1D.运行成功,但不输出
有以下程序:includeincludeusingnameSpacestd;classperson{ intage; Char*nam 有以下程序:include <iostream>include <string>using nameSpace std;class person{int age;Char * name;public:person ( int i, Char * str ){int j;j = strlen( str ) + 1;name = new char[ j ];strcpy( name, str );age = i;}~person(){delete name;cout<<"D";}void display(){cout<<name<<":"<<age;}};int main(){person demo( 30,"Smith" );demo.display();return 0;}则该程序的输出结果为:【 】。
classMyApp{publicstaticvoidmain(String[]args){intage;System.out.println(age=”+age);}}执行上述代码后输出的结果是哪项?() A.age=0B.age=nullC.age=D.程序编译错误
如下两个源程序文件,分别编译后,运行Example.class文件,运行结果为______。AB.java文件代码如下;package test;public class AB{int a=60;public void show(){System.out.println(”a=”+a);}Example.java文件代码如下:import test.AB;class Example{public static void main(String args[]){AB bj=new AB();obj.show();}}
下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}A.编译错误B.0C.1D.运行成功,但不输出
阅读下面代码 public class Test { String s="One World One Dream"; public static void main(String[] args) { System.out.println(s); } } 其运行的结果是A.argsB.World One DreamC.sD.编译时出错
给出下列的不完整的类代码,则下列的( )语句可以加到横线处。 class Person{ String name,department; int age public Person(String n){name=n;} public Person(String n,int a){name=n;age=a;} pubilc Person(String n,String d,int a) { _______________ department=d; } }A.Person(n,a);B.this(Person(n,a));C.this(n,a);D.this(name,age);
根据下面的程序,可以在主程序中使用的合法语句是( )。 include using namesp 根据下面的程序,可以在主程序中使用的合法语句是( )。 #include <iostream> using namespace std; class Person{ int age; public: void SetAge(int x){age=x;} void ShowAge(){cout<<"the Person's age is" <<age;} }; class Student:private Person{ public:int study_code; }; void main(){ Student wangqiang; wangqiang.study_code=23; }A.wangqiang.age=231B.wangqiang.Setage(23)C.wangqiang.ShowAge()D.wangqiang.study_code=12
下面代码的运行结果是 public class Test{ public static void main(String args[]){ for(int i=0; i<3;i++){ if(i<2) continue; System.out.println(i); } } }A.0B.1C.2D.3
给出下面不完整的类代码,则横线处的语句应该为( )。 class Person { String name,department; int age; public Person (Strings) {name=s;} public Person (String s,intA.{name=s;age=a;} public Person (String n,String d,intA){ __________ department=d; } }A)Person (n,A);B.this (Person(n,A));C.this(n,A);D.this(name,age);
根据下面的程序,可以在主程序中使用的合法语句是( )。 include using namespa 根据下面的程序,可以在主程序中使用的合法语句是( )。 #include <iostream> using namespace std; class Person{ int age; voidtest(){} public: Person(intage){this->age=age;} void ShowAge(){cout<<"the Person's age is",<<age;} }; void main(){ Person wang(23); }A.wang.age=45B.wang.wang(45)C.wang.ShowAge()D.wang.test()
下列代码的执行结果是( )。public class Test{public int aMethod( ){static int i=0;i++;System.out.println(i):}public static void main (String args[]){Trest test=new Test ( );test aMethod( ):}}A.编译错误B.0C.1D.运行成功,但不输出B.C.D.
给出下列的不完整的类代码,则下列的哪个语句可以加到横线处? class Person { String name,department; int age; public Person( String n ){ name = n;} public Person( String n,int a ) { name = n;age = a;} public Person( String n,String d,int a ) { _____________ department = d; } }A.Person(n,a);B.this(Person(n,a) );C.this(n,a);D.this(name,age);
Person p = new Person(“张三”,23);这条语句会调用下列哪个构造方法给属性进行初始化() A.public Person(){}B.public Person(String name,int age) { this.name = name; this.age = age; }C.public Person(int age,String name) { this.age = age; this.name = name; }D.public Person(String name) { this.name = name; }
以下程序调试结果为:public class Test {int m=5;public void some(int x) {m=x;}public static void main(String args []) {new Demo().some(7);}}class Demo extends Test {int m=8;public void some(int x) {super.some(x);System.out.println(m);}}A.5B.8C.7D.无任何输出E.编译错误
执行以下代码,输出结果的结果是? () public class Test{ public String[] ss = new String[5]; public static void main(String[] args){ System.out.println(ss[1]); } } A、 nullB、 -1C、 编译时出错D、 运行时报错
public class Person { private String name, comment; private int age; public Person(String n, int a, String c) { name = n; age = a; comment = c; } public boolean equals(Object o) { if(! (o instanceof Person)) return false; Person p = (Person)o; return age == p.age name.equals(p.name); } } What is the appropriate definition of the hashCode method in class Person?() A、 return super.hashCode();B、 return name.hashCode() + age * 7;C、 return name.hashCode() + comment.hashCode() /2;D、 return name.hashCode() + comment.hashCode() / 2 - age * 3;
class MyApp{ public static void main(String[] args){ int age; System.out.println(“age=”+age); } } 执行上述代码后输出的结果是哪项?() A、age=0B、age=nullC、age=D、程序编译错误
单选题class MyApp{ public static void main(String[] args){ int age; System.out.println(“age=”+age); } } 执行上述代码后输出的结果是哪项?()Aage=0Bage=nullCage=D程序编译错误
单选题public class Person { private String name, comment; private int age; public Person(String n, int a, String c) { name = n; age = a; comment = c; } public boolean equals(Object o) { if(! (o instanceof Person)) return false; Person p = (Person)o; return age == p.age name.equals(p.name); } } What is the appropriate definition of the hashCode method in class Person?()A return super.hashCode();B return name.hashCode() + age * 7;C return name.hashCode() + comment.hashCode() /2;D return name.hashCode() + comment.hashCode() / 2 - age * 3;
单选题Given the uncompleted code of a class: class Person { String name, department; int age; public Person(String n){ name = n; } public Person(String n, int a){ name = n; age = a; } public Person(String n, String d, int a) { // doing the same as two arguments version of constructor // including assignment name=n,age=a department = d; } } Which expression can be added at the "doing the same as..." part of the constructor?()A Person(n,a);B this(Person(n,a));C this(n,a);D this(name,age);
单选题执行以下代码,输出结果的结果是? () public class Test{ public String[] ss = new String[5]; public static void main(String[] args){ System.out.println(ss[1]); } }A nullB -1C 编译时出错D 运行时报错