在Java中,运行下面的代码结果是 public class Foo implements Runnable {

分类: 中级Java开发工程师 发布时间: 2023-11-03 11:08 浏览量: 0

在Java中,运行下面的代码结果是 public class Foo implements Runnable { public void run (Thread t) { System.out.println("Running."); } public static void main (String[] args) { new Thread(new Foo()).start(); } }

A.运行时抛出一个异常

B.程序能够运行,但是没有任何输出

C.没有实现 Runnable 接口中的方法导致编译错误

D.程序运行后输出“Running”

正确答案是C