c# 类对象和实例对象_C#类和对象能力问题 套装4
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");} }Hello World
HelloWorld
Syntax Error
Runtime Exception
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 " ) ;} }你好,世界
你好,世界
語法錯誤
運行時異常
正確答案: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, 2
12
Syntax Error
Runtime Exception
Correct answer: 1
1, 2
The above code will print (1, 2) on the console screen.
2)給定代碼段的正確輸出是什么?一二
12
語法錯誤
運行時異常
正確答案: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, 2
12
Syntax Error
Runtime Exception
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 ( ) ;} }一二
12
語法錯誤
運行時異常
正確答案: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();} }####, @@@@, $$$$,
$$$$, @@@@, ####,
Syntax Error
Runtime Exception
Correct answer: 1
####, @@@@, $$$$,
The above code will print (####, @@@@, $$$$,) on console screen.
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();} }Hello World
Hello world
Syntax Error
Runtime Exception
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 ( ) ;} }你好,世界
你好,世界
語法錯誤
運行時異常
正確答案: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的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 宽带要多少钱啊?
- 下一篇: 极米z5腾讯定制怎样进入设置