<ruby id="h6500"><table id="h6500"></table></ruby>
    1. <ruby id="h6500"><video id="h6500"></video></ruby>
          1. <progress id="h6500"><u id="h6500"><form id="h6500"></form></u></progress>
            • 軟件測試技術(shù)
            • 軟件測試博客
            • 軟件測試視頻
            • 開(kāi)源軟件測試技術(shù)
            • 軟件測試論壇
            • 軟件測試沙龍
            • 軟件測試資料下載
            • 軟件測試雜志
            • 軟件測試人才招聘
              暫時(shí)沒(méi)有公告

            字號: | 推薦給好友 上一篇 | 下一篇

            C/C++/C#面試題精選

            發(fā)布: 2011-3-09 10:39 | 作者: 何海濤 | 來(lái)源: 本站原創(chuàng ) | 查看: 131次 | 進(jìn)入軟件測試論壇討論

            領(lǐng)測軟件測試網(wǎng)

              題目(11):運行下圖中的C#代碼,輸出是什么?

              namespace StringValueOrReference

              {

              class Program

              {

              internal static void ValueOrReference(Type type)

              {

              String result = "The type " + type.Name;

              if (type.IsValueType)

              Console.WriteLine(result + " is a value type.");

              else

              Console.WriteLine(result + " is a reference type.");

              }

              internal static void ModifyString(String text)

              {

              text = "world";

              }

              static void Main(string[] args)

              {

              String text = "hello";

              ValueOrReference(text.GetType());

              ModifyString(text);

              Console.WriteLine(text);

              }

              }

              }

              答案:輸出兩行。第一行是The type String is reference type. 第二行是hello。類(lèi)型String的定義是public sealed class String {...},既然是class,那么String就是引用類(lèi)型。

              在方法ModifyString里,對text賦值一個(gè)新的字符串,此時(shí)改變的不是原來(lái)text的內容,而是把text指向一個(gè)新的字符串"world"。由于參數text沒(méi)有加ref或者out,出了方法之后,text還是指向原來(lái)的字符串,因此輸出仍然是"hello".

              題目(12):運行下圖中的C++代碼,輸出是什么?

              #include

              class A

              {

              private:

              int n1;

              int n2;

              public:

              A(): n2(0), n1(n2 + 2)

              {

              }

              void Print()

              {

              std::cout << "n1: " << n1 << ", n2: " << n2 << std::endl;

              }

              };

              int _tmain(int argc, _TCHAR* argv[])

              {

              A a;

              a.Print();

              return 0;

              }

              答案:輸出n1是一個(gè)隨機的數字,n2為0。在C++中,成員變量的初始化順序與變量在類(lèi)型中的申明順序相同,而與它們在構造函數的初始化列表中的順序無(wú)關(guān)。因此在這道題中,會(huì )首先初始化n1,而初始n1的參數n2還沒(méi)有初始化,是一個(gè)隨機值,因此n1就是一個(gè)隨機值。初始化n2時(shí),根據參數0對其初始化,故n2=0。

            延伸閱讀

            文章來(lái)源于領(lǐng)測軟件測試網(wǎng) http://kjueaiud.com/

            31/3123>

            關(guān)于領(lǐng)測軟件測試網(wǎng) | 領(lǐng)測軟件測試網(wǎng)合作伙伴 | 廣告服務(wù) | 投稿指南 | 聯(lián)系我們 | 網(wǎng)站地圖 | 友情鏈接
            版權所有(C) 2003-2010 TestAge(領(lǐng)測軟件測試網(wǎng))|領(lǐng)測國際科技(北京)有限公司|軟件測試工程師培訓網(wǎng) All Rights Reserved
            北京市海淀區中關(guān)村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
            技術(shù)支持和業(yè)務(wù)聯(lián)系:info@testage.com.cn 電話(huà):010-51297073

            軟件測試 | 領(lǐng)測國際ISTQBISTQB官網(wǎng)TMMiTMMi認證國際軟件測試工程師認證領(lǐng)測軟件測試網(wǎng)

            老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月
              <ruby id="h6500"><table id="h6500"></table></ruby>
              1. <ruby id="h6500"><video id="h6500"></video></ruby>
                    1. <progress id="h6500"><u id="h6500"><form id="h6500"></form></u></progress>