这段代码是如何运行的? [英] How this code is Running?

查看:74
本文介绍了这段代码是如何运行的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  interface  i1  extends  Object 
{
void show();
}
class Sigma implements i1
{
public void show()
{
System.out.println( Hanosh);
}
public String toString()
{
return Manish;
}
public static void main( String arg [])
{
i1 i = new Sigma();
i.show();
String s = i.toString();
}
}

解决方案

我不确定这个问题的意图,但我很确定你需要开始阅读有关编程和这个特定语言的内容。



但是,让我列出程序涵盖的区域:

任何程序都通过一个名为 Main 功能的入口点启动。



http://en.wikipedia.org/wiki/Entry_point [ ^ ]



函数中的第一个语句实例化Sigma class 的新对象。



http://en.wikipedia.org/wiki / Class_(computer_programming) [ ^ ]



你还会注意到这个类实现了一个特定的界面



http://en.wikipedia.org/wiki/Interface_(computing) [ ^ ]



这里看到的一些其他概念是静态成员和成员的访问级别(公共,私人等)



http://en.wikipedia.org/wiki/Method_(computer_programming)#Static_methods [ ^ ]



http://msdn.microsoft.com/en-us/library/ms173121.aspx [ ^ ]


这不是魔法 - 但它不是也很容易解释。从这里开始阅读: Jave教程:继承 [ ^ ]完成后,你应该有更好的主意。

interface i1 extends Object
{
	void show();
}
class Sigma implements i1
{
	public void show()
	{
		System.out.println("Hanosh");
	}
	public String toString()
	{
		return "Manish";
	}
	public static void main(String arg[])
	{
		i1 i=new Sigma();
		i.show();
		String s=i.toString();
	}
}

解决方案

I am not sure the intention of this question, but I am quite sure that you need to start reading about programming and this particular language in question.

However, let me list down the areas which program cover:
Any program starts via an Entry Point which is called as Main Function.

http://en.wikipedia.org/wiki/Entry_point[^]

The first statement in the function instantiates a new object of Sigma class.

http://en.wikipedia.org/wiki/Class_(computer_programming)[^]

What you would also notice that this class implements a particular interface.

http://en.wikipedia.org/wiki/Interface_(computing)[^]

Some other concepts which would see here are static members and the access levels of members (Public, Private etc.)

http://en.wikipedia.org/wiki/Method_(computer_programming)#Static_methods[^]

http://msdn.microsoft.com/en-us/library/ms173121.aspx[^]


It's not magic - but it's not simple to explain either. Start reading here: The Jave Tutorials: Inheritance[^] when you have finished, you should have a better idea.


这篇关于这段代码是如何运行的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆