c# 类对象和实例对象

1) What are the correct statements about given code snippets?

using System;
public class Example
{virtual private int X;
private int Y;
static void Main(string[] args)
{Console.WriteLine("Hello World");
}
}

  1. Hello World

  2. HelloWorld

  3. Syntax Error

  4. Runtime Exception

Answer & Explanation

Correct answer: 3
Syntax Error

The above code will generate a syntax error.

The output would be,

1)关于给定代码段的正确陈述是什么?

 using System ;
public class Example
{
virtual private int X ;
private int Y ;
static void Main ( string [ ] args )
{
Console . WriteLine ( " Hello World " ) ;
}
}

  1. 你好,世界

  2. 你好,世界

  3. 语法错误

  4. 运行时异常

答案与解释

正确答案:3
语法错误

上面的代码将生成语法错误。

输出将是

2) What is the correct output of given code snippets?

using System;
public class Example
{private int X;
private int Y;
Example()
{this.X = 1;
this.Y = 2;
}
static void Main(string[] args)
{Example Ob = new Example();
Console.WriteLine("{0}, {1}", Ob.X, Ob.Y);
}
}

  1. 1, 2

  2. 12

  3. Syntax Error

  4. Runtime Exception

Answer & Explanation

Correct answer: 1
1, 2

The above code will print (1, 2) on the console screen.

2)给定代码段的正确输出是什么?

  1. 一二

  2. 12

  3. 语法错误

  4. 运行时异常

答案与解释

正确答案:1
一二

上面的代码将在控制台屏幕上打印(1,2)。

3) What is the correct output of given code snippets?

using System;
public class Example
{private int X;
private int Y;
public Example()
{this.X = 1;
this.Y = 2;
}
public static ShowData()
{Console.WriteLine("{0}, {1}", this.X, this.Y);
}
static void Main(string[] args)
{Example Ob = new Example();
Ob.Show();
}
}

  1. 1, 2

  2. 12

  3. Syntax Error

  4. Runtime Exception

Answer & Explanation

Correct answer: 3
Syntax Error

The above code will generate a syntax error.

The output would be,

3)给定代码段的正确输出是什么?

 using System ;
public class Example
{
private int X ;
private int Y ;
public Example ( )
{
this . X = 1 ;
this . Y = 2 ;
}
public static ShowData ( )
{
Console . WriteLine ( " {0}, {1} " , this . X , this . Y ) ;
}
static void Main ( string [ ] args )
{
Example Ob = new Example ( ) ;
Ob . Show ( ) ;
}
}

  1. 一二

  2. 12

  3. 语法错误

  4. 运行时异常

答案与解释

正确答案:3
语法错误

上面的代码将生成语法错误。

输出将是

4) What is the correct output of given code snippets?

using System;
public class Example
{public Example Method1()
{Console.Write("####, ");
return this;
}
public Example Method2()
{Console.Write("@@@@, ");
return this;
}
public Example Method3()
{Console.Write("$$$$, ");
return this;
}
static void Main(string[] args)
{Example Ob = new Example();
Ob.Method1().Method2().Method3();
}
}

  1. ####, @@@@, $$$$,

  2. $$$$, @@@@, ####,

  3. Syntax Error

  4. Runtime Exception

Answer & Explanation

Correct answer: 1
####, @@@@, $$$$,

The above code will print (####, @@@@, $$$$,) on console screen.

4)给定代码段的正确输出是什么?

  1. ####,@@@@,$$$$,

  2. $$$$,@@@@,####,

  3. 语法错误

  4. 运行时异常

答案与解释

正确答案:1
####,@@@@,$$$$,

上面的代码将在控制台屏幕上打印(####,@@@@,$$$$)。

5) What is the correct output of given code snippets?

using System;
public class Example
{public void SayHello()
{Console.Write("Hello World");
}
static void Main(string[] args)
{this.Method();
}
}

  1. Hello World

  2. Hello world

  3. Syntax Error

  4. Runtime Exception

Answer & Explanation

Correct answer: 3
Syntax Error

In C#.NET we cannot use "this" reference in a static method.

The output would be,

5)给定代码段的正确输出是什么?

 using System ;
public class Example
{
public void SayHello ( )
{
Console . Write ( " Hello World " ) ;
}
static void Main ( string [ ] args )
{
this . Method ( ) ;
}
}

  1. 你好,世界

  2. 你好,世界

  3. 语法错误

  4. 运行时异常

答案与解释

正确答案:3
语法错误

在C#.NET中,我们不能在静态方法中使用“ this”引用。

输出将是

◀ C# Class & Object Aptitude | Set 3 C# Class & Object Aptitude | Set 5 ▶
#C#类和对象的适应性| 设置3 C#类和对象的适应性| 设置5▶

翻译自: https://www.includehelp.com/dot-net/csharp-class-object-aptitude-questions-and-answers-4.aspx

c# 类对象和实例对象

c# 类对象和实例对象_C#类和对象能力问题 套装4相关推荐

  1. python类属性和实例属性_Python 类属性与实例属性,类对象与实例对象用法分析...

    本文实例讲述了Python 类属性与实例属性,类对象与实例对象用法.分享给大家供大家参考,具体如下: demo.py(类属性,所有实例对象共用类属性): # 定义工具类 继承object是为了兼容py ...

  2. python类初始化返回实例_Python基础——类、实例及初始化

    一.面向对象编程 我们最开始写代码是面向过程编程的,即:一步步按顺序去实现 后来我们学习了函数,把这些功能封装到函数里面,需要实现某个功能的时候直接调用就行,这样可以减少代码的重复性,这就是函数式编程 ...

  3. java类成员和实例成员,面向对象Java实验:实验二 类封装,实例成员与类成员,包...

    面向对象Java实验:实验二 类封装,实例成员与类成员,包 程序1: class Trangle { double sideA,sideB,sideC,area,length; boolean boo ...

  4. python 类可以调用实例变量_python面向对象中类对象、实例对象、类变量、实例变量、类方法、实例方法、静态方法...

    1. 类对象和实例对象 Python中一切皆对象,Python类本身也是一种对象,类定义完成后,会在当前作用域中定义一个以类名为名字的命名空间.类对象具有以下两种操作: 可以通过"类名()& ...

  5. vba 定义类_神通广大的类,瞬间实例多个类对象

    你已选中了添加链接的内容蓝字关注,加微信NZ9668获资料信息  VBA解决方案   系列丛书作者  头条百家平台 VBA资深创作者 _______________________________ 大 ...

  6. c#类属性和实例属性_C#中类的序列化及反序列化简要分析

    1.什么是序列化 序列化是将对象状态转换为可保持或传输的格式的过程,在序列化过程中,对象的公共字段和私有字段以及类的名称(包括包含该类的程序集)都被转换为字节流,然后写入数据流. 与序列化相对的是反序 ...

  7. java 对象和实例有什么区别_对象和实例之间的区别

    " 类别"一词来自" 分类"(将类别放入其中的" 类别"),现在我们都听说" 类别"就像一个蓝图,但这到底是什么意思?这 ...

  8. c++ 模板类实现堆栈实验报告_C++类模板实现栈

    定义类模板: template class 类名 {.....}; stack.h #define maxsize 10 template class myStack { private: type ...

  9. java友元类_友元实例:友元类及友元函数

    学习了c++这么久,一直没有对友元进行了解,据说友元不是特别好用(据说,不是我说的),因此直到今天才去了解.其实友元确实不是很常用,但友元功能确实很实用,它不但能够释放类中的非公有成员,同时还能保证了 ...

  10. python中实例和对象的区别,python类对象和实例对象有什么区别吗

    python类对象和实例对象有什么区别吗 发布时间:2020-07-20 14:10:37 来源:亿速云 阅读:119 作者:清晨 这篇文章主要介绍python类对象和实例对象有什么区别吗,文中介绍的 ...

最新文章

  1. 【转】HashMap、TreeMap、Hashtable、HashSet和ConcurrentHashMap区别
  2. 机器学习算法基础(基础机器学习课程)——第一天
  3. 云炬随笔20211021(2)
  4. 篇二:Eclipse安装配置Maven
  5. c 结构体 不允许使用不完整的类型_.NET Core 基础类型介绍
  6. c++ memcpy与strcpy的比较
  7. tableViewCell的操作
  8. 不要钱还免安装!Photoshop杀手火了,网友:作者是上帝么?
  9. 使用Opencv将RGB颜色空间转换到HSV颜色空间/灰度图
  10. java文件 空心_解决Eclipse中java文件的图标变成空心J的问题
  11. 随机森林基本原理与算法描述
  12. python 论坛自动发帖功能
  13. 电脑有网但是浏览器无法显示网页
  14. NB-IoT、LoRa、eMTC、Zigbee、Sigfox、WiFi、蓝牙,谁能称霸物联网时代
  15. matlab双边滤波处理点云,常见点云滤波算法
  16. 04 分布式文件系统以及MapReduce入门程序
  17. 李子柒为什么可以火爆全球
  18. 购买网易企业邮箱后,怎么用手机移动端办公?
  19. 免费打造自己的个人网站,免费域名、免费空间、FTP、数据库什么的,一个不能少,没钱,也可以这么任性...
  20. MySQL5.5版本服务端安装图解

热门文章

  1. NodeJS中resolve添加地址无效
  2. 不一样的ZTree,权限树.js插件
  3. IE9真的支持CSS3和HTML5?
  4. 使用内存回流的方法来实现将image的内容转换为 byte[]
  5. vue 简单实用的elementUI表格封装
  6. VMware配置linux网络步骤
  7. django QuerySet对象转换成字典对象
  8. BZOJ - 4520 K远点对
  9. Windows 10 IoT Core 17101 for Insider 版本更新
  10. HTTPS 通俗简介