单选题class Mineral {   static String shiny() { return "1"; }   }   class Granite extends Mineral {   public static void main(String [] args) {   String s = shiny() + getShiny();   s = s + super.shiny();   System.out.println(s);   }   static String getShiny() { return shiny(); }   }   结果为:()A3B12C111D编译失败

单选题
class Mineral {   static String shiny() { return "1"; }   }   class Granite extends Mineral {   public static void main(String [] args) {   String s = shiny() + getShiny();   s = s + super.shiny();   System.out.println(s);   }   static String getShiny() { return shiny(); }   }   结果为:()
A

3

B

12

C

111

D

编译失败


参考解析

解析: 暂无解析

相关考题:

下面是一个类的定义,试将程序补充完整。class A{String s;____int a=66;A(String sl){s=sl;}static int geta(){return a;}}

下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new TeA.0B.1C.2D.3

classMineral{staticStringshiny(){return1;}}classGraniteextendsMineral{publicstaticvoidmain(String[]args){Strings=shiny()+getShiny();s=s+super.shiny();System.out.println(s);}staticStringgetShiny(){returnshiny();}}结果为:()A.3B.12C.111D.编译失败

下列程序段中,正确的是______。 ①class MvClass { int var = 100; static int getVar() { return var; } } ②public class MyClass { final int date; void MyClass (int d) { date = d; } } ③public class MyMain { public static void main(String args[]) { System.out.println(Myclass1.date); } } class MyClass1 { int data = 10; } ④class IamAbstract { final int f; double d; abstrct void method(); }A.②④B.①③C.②D.以上都不对

执行下面程序,显示的结果为( )。 public class Test { public static void main (String args[]) { Test t=newTest(); System.out.println (Loverload ("2","3")); } int overload (intx,int y) {return x+y;} String overload (String x,Stnng y){return x+y;} }A.2B.3C.5D.23

public class Something {public static void main(String[] args) {Something s = new Something();System.out.println("s.doSomething() returns " + doSomething());}public String doSomething() {return "Do something ...";}}看上去很完美。

4 . 写出程序的输出结果class Class1 {private string str = "Class1.str";private int i = 0;static void StringConvert(string str) {str = "string being converted.";}static void StringConvert(Class1 c) {c.str = "string being converted.";}static void Add(int i) {i++;}static void AddWithRef(ref int i) {i++;}static void Main() {int i1 = 10;int i2 = 20;string str = "str";Class1 c = new Class1();Add(i1);AddWithRef(ref i2);Add(c.i);StringConvert(str);StringConvert(c);Console.WriteLine(i1);Console.WriteLine(i2);Console.WriteLine(c.i);Console.WriteLine(str);Console.WriteLine(c.str);}}

现有  class Parser extends Utils {  public static void main (String  []  args)  {  try  {  System.out.print (new Parser () .getlnt ("42"))       }  catch (Exception e) {  System.out.println ("Exc") ;  }      }  int getlnt (String arg)  throws Exception  {     return Integer.parselnt (arg) ;      }      }  class Utils {  int getlnt ()  {  return 42;  }     }  结果是什么?()      A、 42ExcB、 ExcC、 42D、编译失败

class Mineral {   static String shiny() { return "1"; }   }   class Granite extends Mineral {   public static void main(String [] args) {   String s = shiny() + getShiny();   s = s + super.shiny();   System.out.println(s);   }   static String getShiny() { return shiny(); }   }   结果为:()  A、3B、12C、111D、编译失败

public class OuterClass {  private double d1  1.0;  //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?() A、 static class InnerOne {  public double methoda() {return d1;}  }B、 static class InnerOne {  static double methoda() {return d1;} }C、 private class InnerOne {  public double methoda() {return d1;} }D、 protected class InnerOne {  static double methoda() {return d1;} }E、 public abstract class InnerOne {  public abstract double methoda();  }

1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()  A、 static class InnerOne { public double methoda() { return d1; } }B、 static class InnerOne { static double methoda() { return d1; } }C、 private class InnerOne { public double methoda() { return d1; } }D、 protected class InnerOne { static double methoda() { return d1; } }E、 public abstract class InnerOne { public abstract double methoda(); }

class A {  public byte getNumber() {  return 1;  }  }  class B extends A {  public short getNumber() {  return 2;  }  public static void main(String args[]) {  B b = new B();  System.out.println(b.getNumber()); }  }   What is the result?()A、 1B、 2C、 An exception is thrown at runtime.D、 Compilation fails because of an error in line 8.E、 Compilation fails because of an error in line 14.

interface Beta {}  class Alpha implements Beta {  String testIt() {  return “Tested”;  }  }  public class Main1 {  static Beta getIt() {  return new Alpha();  }  public static void main( String[] args ) {  Beta b = getIt();  System.out.println( b.testIt() );  }  }  What is the result?()  A、 TestedB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.

定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()     A、import utils.*;B、 import utils.Rep.*;C、 import static utils.Rep.twice;D、 static import utils.Rep.twice;

Which is the earliest line in the following code after which the object created on the line marked (0) will be a candidate for being garbage collected, assuming no compiler optimizations are done? ()  public class Q76a9 {   static String f() {   String a = "hello";   String b = "bye"; // (0)   String c = b + "!"; // (1)   String d = b;  b = a; // (2)   d = a; // (3)   return c; // (4)  }   public static void main(String args[]) {   String msg = f();   System.out.println(msg); // (5)   }   }  A、The line marked (1).B、The line marked (2).C、The line marked (3).D、The line marked (4).E、The line marked (5).

class Parser extends Utils {  public static void main(String [] args) {   System.out.print(new Parser().getInt("42"));  }  int getInt(String arg) {  return Integer.parseInt(arg);  }  }  class Utils {  int getInt(String arg) throws Exception { return 42; }  }  结果为:() A、42B、编译失败C、无输出结果D、运行时异常被抛出

单选题现有:  class Tree {  private static String tree = "tree ";  String getTree ()  {  return tree;  }       }  class Elm extends Tree {  private static String tree = "elm ";  public static void main (String  []  args)  {       new Elm() .go (new Tree())  ;      } }  void go (Tree t)  {  String  s =  t.getTree () +Elm.tree  +  tree  +   (new  Elm() .getTree ()) ;      System.out.println (s) ;}     结果为:()A elm elm elm elmB tree elm elm elmC tree elm elm treeD tree elm tree elm

单选题class Parser extends Utils {  public static void main(String [] args) {   System.out.print(new Parser().getInt("42"));  }  int getInt(String arg) {  return Integer.parseInt(arg);  }  }  class Utils {  int getInt(String arg) throws Exception { return 42; }  }  结果为:()A42B编译失败C无输出结果D运行时异常被抛出

单选题interface Beta {}  class Alpha implements Beta {  String testIt() {  return “Tested”;  }  }  public class Main1 {  static Beta getIt() {  return new Alpha();  }  public static void main( String[] args ) {  Beta b = getIt();  System.out.println( b.testIt() );  }  }  What is the result?()A TestedB Compilation fails.C The code runs with no output.D An exception is thrown at runtime.

单选题final class Tree {  private static String tree = "tree ";  String getTree() { return tree; }  }  class Elm extends Tree {  private static String tree = "elm "; public static void main(String [] args) {  new Elm().go(new Tree());  }  void go(Tree t) {  String s = t.getTree()+Elm.tree+tree+(new Elm().getTree());  System.out.println(s);  } }  结果为:()Aelm elm elm elmBtree elm elm elmCtree elm tree elmD编译失败

多选题1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()Astatic class InnerOne { public double methoda() { return d1; } }Bstatic class InnerOne { static double methoda() { return d1; } }Cprivate class InnerOne { public double methoda() { return d1; } }Dprotected class InnerOne { static double methoda() { return d1; } }Epublic abstract class InnerOne { public abstract double methoda(); }

单选题现有:  class Guy  {  String greet()  {  return "hi";  } } class Cowboy extends Guy  {  String greet()  {  return. "howdy";}}  class  Wrangler  extends  Cowboy  {  String  greet()  {  return  "orch!"; } }  class Greetings2  {  public  static void main (String  []  args)  {  Guy g=new Wrangler();  Guy g2=new Cowboy();  Wrangler w2=new Wrangler();  System. out .print (g.greet()+g2.greet()+w2 .greet());  }  }  结果是什么?()A hi hi ouch!B ouch!  howdy  ouch!C hi howdy ouch!D编译失败E运行的咐候有异常抛出

多选题public class OuterClass {   private double d1 1.0;   //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()Astatic class InnerOne {  public double methoda() {return d1;}  }Bstatic class InnerOne {  static double methoda() {return d1;}  }Cprivate class InnerOne {  public double methoda() {return d1;}  }Dprotected class InnerOne {  static double methoda() {return d1;}  }Epublic abstract class InnerOne {  public abstract double methoda();  }

单选题现有:  class Guy {String greet()    {return "hi";  }  }  class Cowboy extends Guy  (  String greet()    (  return "howdy  ¨;    )  )  class Surfer extends Guy  (String greet()    (return "dude! ";)) class Greetings  {  public static void main (String  []  args)    {  Guy  []  guys =  ( new Guy(), new Cowboy(), new Surfer()  );  for (Guy g:  guys) System.out.print (g.greet()};  }  }  结果为:()A hi howdy dude!B运行时异常被抛出。C第7行出现一个错误,编译失败。D第8行出现一个错误,编译失败。

单选题class Guy { String greet() { return "hi "; } }  class Cowboy extends Guy { String greet() { return "howdy "; } }  class Wrangler extends Cowboy { String greet() { return "ouch! "; } }  class Greetings2 {  public static void main(String [] args) {  Guy g = new Wrangler();  Guy g2 = new Cowboy();  Wrangler w2 = new Wrangler();  System.out.print(g.greet()+g2.greet()+w2.greet());  }  }  结果是什么?()Ahi hi ouch!Bhi howdy ouch!Couch! howdy ouch!D编译失败

单选题Given a class Repetition:  1. package utils;  2.  3. public class Repetition {  4. public static String twice(String s) { return s + s; }  5. }  and given another class Demo:  1. // insert code here 2.  3. public class Demo {  4. public static void main(String[] args) {  5. System.out.println(twice(”pizza”));  6. }  7. }  Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()A import utils.*;B static import utils.*;C import utils.Repetition.*;D static import utils.Repetition. *;E import utils.Repetition.twice();F import static utils.Repetition.twice;G static import utils.Repetition.twice;

单选题现有:  class Parser (类)extends(继承) Utils {   public static void main(String [] args) {   System.out.print(输出打印)(new Parser().getInt("42"));  }   int getInt(String arg) {   return Integer.parseInt(arg);    }   }   class Utils {   int getInt(String arg) throws Exception { return 42; }  }   结果为:()A 42B 编译失败。C 无输出结果。D 运行时异常被抛出。