Nanjing University of Posts and Telecommunications Java programming job on-line programming sixth time

Source: Internet
Author: User

Wang Li's "Java language programming 6th time Job (2018)" Details
    1. Home
    2. My list of jobs
    3. Job Result Details
Score:Select a question score:1. The parent class of all classes in Java is (). A.fatherB.langC.classD.objectthe correct answer is: D2. The following description of abstract classes and abstract methods is correct (). A. Abstract methods can exist in non-abstract classes. B. Abstract classes can contain non-abstract methods. C. Abstract methods contain method bodies, except that the method body is empty. D. The return value type of the abstract method must be invalid. the correct answer is: B3. Subclasses must invoke the constructor of the parent class through the ____________ keyword. A.extendsB.thisC.superD.fatherthe correct answer is: C4. Member variables of a class decorated with the keyword ____________ can only be accessed in the class itself. Publicb.privatec.protectedD.packagethe correct answer is: B5. The package that the program runs in Java automatically introduces is ____________. correct answer is: D6. The Java language operator keyword __________ is used to create objects and allocate memory space for objects. a.createB.mallocc.newd.requestthe correct answer is: C7. When an interface is declared using an interface, the data member declared in the interface can only be (). a.private static FinalB. Protection of the finalc.staticD. public static Finalthe correct answer is: D8. The following description of the succession is correct (). A. In the Java class, only single inheritance is allowedB. In Java, a class can implement only one interfaceC. In Java, a class cannot inherit one class at a time and implement an interfaceD. The interface in Java only allows single inheritancethe correct answer is: A9. A variable or method belonging to a class is referred to as a static variable or a static method, preceded by a variable declaration or method declaration with a keyword (). PublicB.classC.interfaced.staticthe correct answer is: D10. Declares that the current file is in a package named MyPackage ()a.package MyPackage;B.import MyPackage;c.package Mypacage. *;D.import MyPackage. *;the correct answer is: A11. For the member variable that is protected by the protected access control modifier, the following statement is correct (). A. Can be referenced by three kinds: the class itself, with it in the same package of other classes, in other packages of the subclass of that classB. Can be accessed and referenced by two kinds: the class itself, all subclasses of the classC. Can only be accessed and modified by the class itselfD. Can only be accessed by classes in the same packagethe correct answer is: A 12. Suppose that class A is defined as follows, where a is an instance of Class A, and the following statement calls the wrong () Class A {static String s; void Method1 () {...} static void Method2 () {...}} a.system.out.println (AS)Bamethod1 ()CAmethod1 ()DAmethod2 ()the correct answer is: CProgram Blanks Score:define an employee class and use that class to program

The main method is already defined.
Please declare a class employee, variable:
(1) member variable name (string type, indicating employee name);
(2) member variable gender (charcoal type, indicating employee gender);
(3) static variable empcount (int type, which represents the total number of employees, with an initial value of 0).
The Employee class includes methods:
(1) Construction method: Used to initialize the member variables in the class, and statistics of the total number of employees;
(2) Providing a method of acquiring and set the name variable;
(3) defines the ToString () method, which requires that the employee's personal information be returned as a string, in the format string: "name:%s \ tgender:%s";

Write the test class main class, generate several instances, and verify the functionality of the program.PublicClassMain {PublicStaticvoidMainString args[]) {Employee S1 =New Employee ("Jack,"' M '); System.Out.println ("After the construction of the S1, the number of employees is:" + employee.empcount); Employee s2 =New Employee ("Rose",' M '); System.Out.println ("After the construction of the S2, the number of employees is:" + employee.empcount); S1.setname ("Tom"); S2.setgender (' F '); System.Out.println (S1.tostring ()); System.Out.println (S2.tostring ());}}Please add your code content after the bankClassEmployee {private String name;Privatechar gender;Staticint empcount =0;PublicEmployee (String name,Char gender) { = name;This.gender = gender; ++empcount; }Public StringGetName () {return name; }PublicvoidSetName (String name) { = name; }PublicCharGetgender () {return gender; }PublicvoidSetgender (Char gender) {this.gender = gender;} static int getempcount (return ++empCount;} public static void setempcount ( int empcount) {employee.empcount = Empcount;} @override  Public String tostring (//string s =, return String.Format ( "name:%s\tgender:%s", Name,gender);}}  
Create a student class and use this class to program

Create a student class and use this class to program
1) Create student class, including the domain has the school number, the class number, the name, the sex age, and all is the private type;
2) Declare a constructor to initialize all the field records of the object to generate the number of students;
3) Declare the public method of obtaining each attribute, declare the method of modifying each property;
4) Declare a public ToString method that synthesizes a string of information groups for all fields in the class, formatted with the following format: "Study number:%s \ t class:%s \ ton Name:%s \ ton Gender:%s \ Ton Age:%d";

Write the main class, generate several instances and verify the functionality of the program, and do not alter the definition of the main class.PublicClassMain {PublicStaticvoidMainString args[]) {Student S1 =New Student ("001","9801","Zhang San","Male",24); System.Out.println ("After the construction of the S1, the number of classes is:" + student.getcount ()); Student s2 =New Student ("002","9801","John Doe","Woman",21); System.Out.println ("After the construction of the S2, the number of classes is:" + student.getcount ()); S1.setname ("Wang Ping"); S2.setage (19); System.Out.println (S1.tostring ()); System.Out.println (S2.tostring ());if (S1.getage () > S2.getage ()) System.Out.println ("The older person's name is:" + s1.getname ());Elsesystem.Out.println ("The older person's name is:" + s2.getname ());}}Please add your code content after the bankClassStudent {Private String StudentID;Private String Clssid;private String name;Private String sex;Privateint age;PrivateStaticint count;PublicStaticIntGetCount () {return count; }PublicStudent (String StudentID, String clssid, string name, String sex,int age) {This.studentid = StudentID;This.clssid = Clssid; = name; = sex;This.age = age; count++; } @OverridePublic StringToString () {Return String.Format ("School Number:%s\t:%s\t name:%s\t Sex:%s\t Age:%d", studentid,clssid,name,sex,age);}Public StringGetName () {return name; }PublicvoidsetName (String name) { = name;} public int getage () { return age;} public void setage (int.) { this.age = age;} public static void setcount (int count) {Student.count = count;}}     

Nanjing University of Posts and Telecommunications Java programming job online programming sixth time job

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: 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.