Java题目,高手麻烦帮忙做一下!
11、按以下要求编写程序(1)编写Computer接口,接口中声明poweron()方法(2)定义PC类和Laptop类实现Computer接口(3)编写PC类和Lapt...
11、按以下要求编写程序
(1) 编写Computer接口,接口中声明poweron() 方法
(2) 定义PC类和Laptop类实现Computer接口
(3) 编写PC类和Laptop类的测试程序,并调用其中的poweron()方法 展开
(1) 编写Computer接口,接口中声明poweron() 方法
(2) 定义PC类和Laptop类实现Computer接口
(3) 编写PC类和Laptop类的测试程序,并调用其中的poweron()方法 展开
4个回答
展开全部
public interface Computer {
public void poweron();
}
class PC implements Computer{
public void poweron() {
System.out.println("PC实现Computer接口");
}
}
class Laptop implements Computer{
public void poweron() {
stem.out.println("Laptop实现Computer接口");
}
}
public class Test {
public static void main(String[] args) {
Computer pc=new PC();
Computer laptop=new Laptop();
pc.poweron();
laptop.poweron();
}
}
public void poweron();
}
class PC implements Computer{
public void poweron() {
System.out.println("PC实现Computer接口");
}
}
class Laptop implements Computer{
public void poweron() {
stem.out.println("Laptop实现Computer接口");
}
}
public class Test {
public static void main(String[] args) {
Computer pc=new PC();
Computer laptop=new Laptop();
pc.poweron();
laptop.poweron();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public interface Computer{ void poweron();}
public class Pc implements Computer{
public void poweron(){
Sysout.out.print("Pc")
}
}
public class Laptop implements Computer{
public void poweron(){
Sysout.out.print("Laptop ")
}
}
public class Test {
public static void main(String[] args){
new Pc().poweron();
new Laptop ().poweron();
}
}
public class Pc implements Computer{
public void poweron(){
Sysout.out.print("Pc")
}
}
public class Laptop implements Computer{
public void poweron(){
Sysout.out.print("Laptop ")
}
}
public class Test {
public static void main(String[] args){
new Pc().poweron();
new Laptop ().poweron();
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
interface Computer{
void poweron()
}
class PC implements Computer{
public void poweron(){
System.out.println('pc');
}
}
class Laptop implements Computer{
public void poweron(){
System.out.println('laptop');
}
}
public class Test{
public staticvoid main(String[] args){
Computer pc = new PC();
pc.poweron();
Computer laptop= new Laptop ();
laptop.poweron();
}
}
void poweron()
}
class PC implements Computer{
public void poweron(){
System.out.println('pc');
}
}
class Laptop implements Computer{
public void poweron(){
System.out.println('laptop');
}
}
public class Test{
public staticvoid main(String[] args){
Computer pc = new PC();
pc.poweron();
Computer laptop= new Laptop ();
laptop.poweron();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public interface Computer{
public void poweron() ;
}
public class PC extends Computer{
public void poweron() {
System.out.println("PC");
}
}
public class Laptop extends Computer{
public void poweron() {
System.out.println("Laptop");
}
}
public class Test{
public static void main(String[] args) {
PC pc = new PC();
pc.poweron();
Laptop laptop = new PC();
laptop.poweron();
}
}
public void poweron() ;
}
public class PC extends Computer{
public void poweron() {
System.out.println("PC");
}
}
public class Laptop extends Computer{
public void poweron() {
System.out.println("Laptop");
}
}
public class Test{
public static void main(String[] args) {
PC pc = new PC();
pc.poweron();
Laptop laptop = new PC();
laptop.poweron();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询