Menu
×
×
正确
// Create a MyClass class
public class @(7) {
int @(1); // Create a class attribute x
// Create a class constructor for the MyClass class
public @(7)() {
x = @(1); // Set the initial value for the class attribute x to 5
}
public static void main(String[] args) {
// Create an myObj object of class MyClass (This will call the constructor)
MyClass @(5) = new MyClass();
// Print the value of x
System.out.println(@(5).@(1));
}
}
// Create a MyClass class
public class MyClass {
int x; // Create a class attribute x
// Create a class constructor for the MyClass class
public MyClass() {
x = 5; // Set the initial value for the class attribute x to 5
}
public static void main(String[] args) {
// Create an myObj object of class MyClass (This will call the constructor)
MyClass myObj = new MyClass();
// Print the value of x
System.out.println(myObj.x);
}
}
不正确
点击 此处 重试 正确
下一题 ❯// Create a MyClass class public classw3exercise_input_no_0{ intw3exercise_input_no_1; // Create a class attribute x // Create a class constructor for the MyClass class publicw3exercise_input_no_2() { x =w3exercise_input_no_3; // Set the initial value for the class attribute x to 5 } public static void main(String[] args) { // Create an myObj object of class MyClass (This will call the constructor) MyClassw3exercise_input_no_4= new MyClass(); // Print the value of x System.out.println(w3exercise_input_no_5.w3exercise_input_no_6); } } |