Q:
Java find output programs (static Keyword) | set 2
belongs to collection: Java find output programs
Java find output programs
- Java find output programs (Data Types) | set 1
- Java find output programs (Data Types) | set 2
- Java find output programs (Data Types) | set 3
- Java find output programs (Operators) | set 1
- Java find output programs (Operators) | set 2
- Java find output programs (Operators) | set 3
- Java find output programs (if else) | set 1
- Java find output programs (if else) | set 3
- Java find output programs (switch case) | set 1
- Java find output programs (switch case) | set 2
- Java find output programs (switch case) | set 3
- Java find output programs (Loops) | set 1
- Java find output programs (Loops) | set 2
- Java find output programs (Loops) | set 3
- Java find output programs (Arrays) | set 1
- Java find output programs (Arrays) | set 2
- Java find output programs (Arrays) | set 3
- Java find output programs (this Keyword) | set 1
- Java find output programs (final Keyword) | set 1
- Java find output programs (final Keyword) | set 2
- Java find output programs (static Keyword) | set 1
- Java find output programs (static Keyword) | set 2
- Java find output programs (Parameter Passing) | set 1
- Java find output programs (Class and Objects) | set 1
- Java find output programs (Class and Objects) | set 2
- Java find output programs (Class and Objects) | set 3
- Java find output programs (Constructor & Destructor) | set 1
- Java find output programs (Constructor & Destructor) | set 2
- Java find output programs (Constructor & Destructor) | set 3
- Java find output programs (Inheritance) | set 1
- Java find output programs (Inheritance) | set 2
- Java find output programs (Inheritance) | set 3
- Java find output programs (Interface) | set 1
- Java find output programs (Interface) | set 2
- Java find output programs (Interface) | set 3
- Java find output programs (Overloading) | set 1
- Java find output programs (Overloading) | set 2
- Java find output programs (Overriding) | set 1
- Java find output programs (Overriding) | set 2
- Java find output programs (Overriding) | set 3
- Java find output programs (Exception Handling) | set 1
- Java find output programs (Exception Handling) | set 2
- Java find output programs (Exception Handling) | set 3
- Java find output programs (Enumeration) | set 1
- Java find output programs (Enumeration) | set 2
- Java find output programs (Autoboxing & Unboxing) | set 1
- Java find output programs (Autoboxing & Unboxing) | set 2
- Find output programs (Java String class)
- Find Output of Java program - 1 (Mixed topics)
- Find Output of Java program - 2 (Mixed topics)
- Java find output programs (if else) | set 2
Answer Question 1:
Output:
Explanation:
The above program will generate a syntax error because here we created the Sample class as a static, but we cannot create a static class in java.
Answer Question 2:
Output:
Explanation:
The above program will generate syntax error because we cannot create a static constructor in java. Here, we created a static constructor in Sample class.
Answer Question 3:
Output:
Explanation:
The above program will generate a syntax error because we used non-static data member balance in static method printBalance().
Answer Question 4:
Output:
Explanation:
In the above program, we created a Customer class that contains a non-static member balance and a static member BankBalance. Here, we created one constructor and printBalance() method.
The constructor of Customer class is used to initialize data member balance and add balance value to the static variable BankBalance. The static member BankBalance represents the sum of all balances for all customers.
Now look to the main() method, here we created the objects C1 and C2 of customer class and initialized each object of Customer class with some initial value. Then print the balance of the customer as well as print the bank balance on the console screen.
Answer Question 5:
Output:
Explanation:
The above program will generate syntax errors because of the below statements,
static Customer C1 = new Customer(1000); C1.printBalance(); static Customer C2 = new Customer(2000); C2.printBalance();
In the above statements, we created static objects but we cannot create static objects in the java.
need an explanation for this answer? contact us directly to get an explanation for this answer