开发者社区> 问答> 正文

一道Java编程题,求答案

class Test   
{  
    int test_a, test_b;  
    Test(int a, int b)   
    {  
    test_a = a;   
    test_b = b;   
    }  
    public static void main (String args[])   
    {  
        Test test = new Test();   
        System.out.println(test.test_a+" "+test.test_b);  
    }  
}  

展开
收起
YDYK 2020-04-23 23:00:20 412 0
1 条回答
写回答
取消 提交回答
  • 这道题存在编译器错误,因为在main方法中有一个对默认构造函数的调用,而该调用在类中不存在。但是,在Test类中只有一个参数化的构造函数。因此,构造函数不会隐式调用默认构造函数

    2020-04-23 23:00:45
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载