C # knowledge point test

Source: Internet
Author: User

1,String processing problems

Problem description: cyclically receives a string greater than 3 from the keyboard and can be input cyclically. Complete the following functions:

(1) Length of the output string.

(2) the first occurrence of the letter a in the output string.

(3) number of times the substring AB appears in the output string.

(4) After the string contains 3rd characters, insert the string "C #" and output the new string.

(5) Replace "C #" in the string with "Java" and output the new string.

(6) use the character "c" as the separator to split the string and output the separated string.

Test example:

Input example: AB

Output example: Enter at least 3 Characters

Input example: 123abcabc123

Output example: the string length is 12.

The first occurrence of letter a is 3

The substring AB appears twice.

The new string after insertion is 123C # abcabc123

The new string after replacement is 123Javaabcabc123.

The split string using c is:

123 Javaab

AB

123

2. Classes and objects

A parent class:

Age and name (attribute)

Method with return value: speak ()

Two methods without return values: one has a parameter, the other has no parameters, and both methods are sing;

A method without return values: There are two parameters: age and name. The method is Info ();

One child subclass: inherits the parent class

Override the father's Info () method

Write Other content as needed

A daughter class: inherits the father class

There are two shopping methods: goShopping (), goShopping (string clothesName, double clothesPrice );

Override the father's Info ();

3. Date:

Input a date from the keyboard in the format of yyyy-mm-dd

Calculate the number of days between the date and January 1, October 1, 1949.

For example:

User entered: 1949-10-02

Program output: 1

User entered: 1949-11-01

Program output: 31

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.