【西天取经】1、OOP面向对象(C#\JAVA)
2021-02-14 05:17
标签:对象 比较 dem his super cte ted over demo 1、OOP面向对象(C#\JAVA) C#请写出运行结果: JAVA请写出运行结果: JAVA和C#类型比较时的特殊之处,请写出运行结果: 【西天取经】1、OOP面向对象(C#\JAVA) 标签:对象 比较 dem his super cte ted over demo 原文地址:https://www.cnblogs.com/xitianqujing/p/12723924.html class Person
{
protected int Age = 10;
public Person()
{
this.Output();
}
public virtual void Output()
{
Console.WriteLine("Person:" + this.Age);
}
}
class Employee : Person
{
public Employee() : base()
{
base.Age = 20;
}
public override void Output()
{
Console.WriteLine("Employee:" + base.Age);
}
}
class Program
{
static void Main(string[] args)
{
Employee employee = new Employee();
}
}
public class Person {
protected int age = 10;
public Person() {
this.outPut();
}
public void outPut() {
System.out.println("Person:" + this.age);
}
}
public class Employee extends Person {
public Employee() {
super();
super.age = 20;
}
@Override
public void outPut() {
System.out.println("Employee:" + super.age);
}
}
public class CodeDemo {
public static void main(String[] args) {
new Employee();
}
}
public static void main( String[] args ) {
System.out.println("1" == "1");
System.out.println("1".equals("1"));
System.out.println(new String("1") == new String("1"));
System.out.println(new String("1").equals(new String("1")));
System.out.println("1" == new String("1"));
System.out.println("1".equals(new String("1")));
int data1 = 127;
int data2 = 127;
System.out.println(data1 == data2);
Integer dataObject1 = 127;
Integer dataObject2 = 127;
System.out.println(dataObject1 == dataObject2);
Integer dataObj1 = new Integer(127);
Integer dataObj2 = new Integer(127);
System.out.println(dataObj1 == dataObj2);
Integer dataObject11 = Integer.valueOf(127);
Integer dataObject12 = Integer.valueOf(127);
System.out.println(dataObject11 == dataObject12);
int int127 = 127;
System.out.println(int127 == dataObj1);
System.out.println(dataObj1.equals(int127));
System.out.println(int127 == dataObject11);
System.out.println(dataObject11.equals(int127));
data1 = 128;
data2 = 128;
System.out.println(data1 == data2);
dataObject1 = 128;
dataObject2 = 128;
System.out.println(dataObject1 == dataObject2);
dataObj1 = new Integer(128);
dataObj2 = new Integer(128);
System.out.println(dataObj1 == dataObj2);
dataObject11 = Integer.valueOf(128);
dataObject12 = Integer.valueOf(128);
System.out.println(dataObject11 == dataObject12);
int int128 = 128;
System.out.println(int128 == new Integer(128));
System.out.println(new Integer(128).equals(int128));
System.out.println(int128 == Integer.valueOf(128));
System.out.println(Integer.valueOf(128).equals(int128));
}
上一篇:Java——JVM相关
下一篇:双指针算法:盛最多水的容器
文章标题:【西天取经】1、OOP面向对象(C#\JAVA)
文章链接:http://soscw.com/index.php/essay/55095.html