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");
}
}

  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# 類對象和實例對象

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/380065.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/380065.shtml
英文地址,請注明出處:http://en.pswp.cn/news/380065.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

linkBar組件學習--設置linkBar子項的豎直間距.

效果&#xff1a;代碼&#xff1a; <?xml version"1.0" encoding"utf-8"?><!--http://blog.flexexamples.com/2008/04/20/setting-the-vertical-spacing-between-items-in-a-linkbar-control-in-flex/ --><mx:Application xmlns:mx"…

AES算法

算法簡介 AES本質是一種對稱分組密碼體制&#xff0c;采用代替/置換網絡。每輪由三層組成&#xff1a;線性混合層確保多輪之上的高度擴散&#xff0c;非線性層由16個S盒并置起到混淆的作用&#xff0c;秘鑰加密層將子秘鑰異或到中間狀態。 AES加密數據塊和秘鑰長度可以是128比…

C——結構體

例題1&#xff1a;(使用結構體) 輸入兩個學生的學號、姓名和成績&#xff0c;輸出成績較高的學生的學號、姓名和成績 解題思路&#xff1a; (1)定義連個結構相同的結構體變量student1,student2; (2)分別輸入兩個學生的學號、姓名、和成績&#xff1b; (3)比較兩個學生的成…

web.config配置文件詳解

<?xml version"1.0"?> <!--注意: 除了手動編輯此文件以外&#xff0c;您還可以使用 Web 管理工具來配置應用程序的設置。可以使用 Visual Studio 中的“網站”->“Asp.Net 配置”選項。 設置和注釋的完整列表在 machine.config.comments 中&#xff0c…

離散數學群論_離散數學中的群論及其類型

離散數學群論半群 (Semigroup) An algebraic structure (G, *) is said to be a semigroup. If the binary operation * is associated in G i.e. if (a*b) *c a *(b*c) a,b,c e G. For example, the set of N of all natural number is semigroup with respect to the operat…

IDA使用方法-----1

0x01 啟動IDA new&#xff1a;反匯編一個新文件go&#xff1a;運行&#xff0c;直接進入IDAPrevious&#xff1a;載入一個我們以前編譯過的程序 如果不想每次都看到這個對話框&#xff0c;可以取消該對話框底部的Display at startup&#xff08;啟動時顯示&#xff09;&#x…

郵箱驗證JS代碼

方法一,用JSfunction finish_onclick() { var username document.getElementById("username");var pwhidden document.getElementById("pwhidden");if(username.value"") { alert("請填寫您的企業郵箱地址&#xff01;");username.f…

objdump命令詳解

objdump命令是用查看目標文件或者可執行的目標文件的構成的gcc工具。 選項 --archive-headers -a 顯示檔案庫的成員信息,類似ls -l將lib*.a的信息列出。 -b bfdname --targetbfdname 指定目標碼格式。這不是必須的&#xff0c;objdump能自動識別許多格式&#xff0c;比如…

Java——異常(try...catch...finally)

public class Demo5_Throwable {public static void main(String[] args) {try{System.out.println(1/0);}catch(Exception e){System.out.println(e.getMessage());//獲取異常信息,返回字符串&#xff1b;System.out.println(e.toString());//獲取異常類名和異常信息&#xff…

Python程序反轉給定數字(2種不同方式)

Take input number from the user and print its reverse. 從用戶處獲取輸入號碼并打印其反面。 Example: 例&#xff1a; Input:12345Output:54321Here, we are implementing program to reversing a given number using 2 different ways. 在這里&#xff0c;我們正在實施程…

外匯期貨學習專帖(轉)

一篇好文,值得深思! (轉) 我的一些所看所想,和大家聊聊 ; d: R ^6 c* A2 e X" y8 y4 Bhttp://www.fx998.cn 說來慚愧,很久以前,俺在期貨公司混事,95年以前國內期貨公司從外盤棉花到咖啡....,外匯期指到原油.都能*作.是一派欣欣向榮之景.95年之后,按國家規定都轉了內…

《Pro ASP.NET MVC 3 Framework》學習筆記之四【領域模型介紹】

主題&#xff1a;應用領域驅動開發(Applying Domain-Driven Development) Domain Model是MVC程序的"心臟"&#xff0c;其他的一切&#xff0c;包括Controllers和Views僅僅是用來跟Domain Model交互的一種方式&#xff0c;ASP.NET MVC并沒有限制使用在Domain Model上面…

Java——集合框架(List)

集合框架&#xff08;List的三個子類的特點&#xff09; A&#xff1a;List的三個子類的特點 ArrayList&#xff1a; 底層數據結構是數組&#xff0c;查詢快&#xff0c;增刪慢。 線程不安全&#xff0c;效率高。 Vector&#xff1a; 底層數據結構是數組&#xff0c;查詢…

一步一步學pwntools(適合新手)

序 pwntools是一個二進制利用框架。官方文檔提供了詳細的api規范。然而目前并沒有一個很好的新手教程。因此我用了我過去的幾篇writeup。由于本文只是用來介紹pwntools使用方法&#xff0c;我不會過于詳細的講解各種二進制漏洞攻擊技術。 Pwntools的“Hello World” 棧溢出無…

關于J2EE中死鎖問題的研究(1)

大多數重要的應用程序都涉及高度并發性和多個抽象層。并發性與資源爭用有關&#xff0c;并且是導致死鎖問題增多的因素之一。多個抽象層使隔離并修復死鎖環境的工作變得更加困難。 通常&#xff0c;當同時執行兩個或兩個以上的線程時&#xff0c;如果每個線程都占有一個資源并請…

python變量分配內存_Python | 聲明任何變量而不分配任何值

python變量分配內存Since, Python is a dynamic programming language so there is no need to declare such type of variable, it automatically declares when first time value assign in it. 由于Python是一種動態編程語言&#xff0c;因此無需聲明此類變量&#xff0c;它…

UVA 10004 - Bicoloring

模擬染色&#xff0c;因為只有兩種顏色&#xff0c;所以分別用 0、 1 代表這兩種顏色&#xff0c;然后從0開始深搜&#xff0c;如果 每個點都能染上色&#xff0c;且相鄰兩點的顏色不同&#xff0c;則符合要求。 #include<stdio.h>#include<string.h>#define MAXN …

標志寄存器:CF、PF、AF、ZF、SF、TF、DF、OF

注&#xff1a;下面說到的標志寄存器都是縮寫&#xff0c;C就是CF&#xff0c;其他也一樣 標志寄存器&#xff1a;C、P、A、Z、S、T、D、O的內容只會是0或1&#xff0c;0表示假&#xff0c;1表示真 O&#xff1a;溢出標志 一個寄存器如果存放的值超過所能表示的范圍&#xf…

揭秘:銷售人員26個致命弱點

銷售人員有許多積極的態度需要學習&#xff0c; 同時也有許多不良的習慣應該避免&#xff0c;以免影響個性及專業能力。仔細看看這些缺點&#xff0c;反省你自己&#xff0c;還需要改善的畫&#xff0c;直到你給自己一百分為止。找一位深知你的好 友&#xff0c;讓他誠實地給你…

Java——集合(練習題)

例題1&#xff1a;產生10個1~20之間的隨機數&#xff0c;要求隨機數不能重復 import java.util.HashSet; import java.util.Random; public class Test1 {/*** 產生10個1~20之間的隨機數&#xff0c;要求隨機數不能重復* * 分析&#xff1a;* 1,有Random類創建隨機數對象* 2&a…