Podcast
Questions and Answers
Where are member variables defined in a class?
Where are member variables defined in a class?
- As parameters (arguments)
- As class variables (static fields) (correct)
- As local variables
- Inside methods
Which type of method is declared as non-static in a class?
Which type of method is declared as non-static in a class?
- Local method
- Class method
- Static method
- Instance method (correct)
What happens to member variables that are declared but not initialized?
What happens to member variables that are declared but not initialized?
- They are automatically assigned a null value
- They remain uninitialized
- They cause a compilation error
- They are set to a default value by the compiler (correct)
What is the default value for an uninitialized long data type variable?
What is the default value for an uninitialized long data type variable?
Where are static members (variables and methods) of a class defined?
Where are static members (variables and methods) of a class defined?
Which type of variable is used to store the state of an object in a class?
Which type of variable is used to store the state of an object in a class?
What happens if you attempt to compile and run method m in class Test?
What happens if you attempt to compile and run method m in class Test?
How are instance variables of an object accessed from another class?
How are instance variables of an object accessed from another class?
Which of the following correctly accesses instance methods from another class?
Which of the following correctly accesses instance methods from another class?
In the given example, what will be the output of c1.area after calling c1.setArea()?
In the given example, what will be the output of c1.area after calling c1.setArea()?
In the BankAccount class, what happens when you call the withdraw method?
In the BankAccount class, what happens when you call the withdraw method?
What is the purpose of the 'this' keyword in Java?
What is the purpose of the 'this' keyword in Java?
What is the result of attempting to run method m2 in class A?
What is the result of attempting to run method m2 in class A?
What happens if you attempt to access an uninitialized instance variable in Java?
What happens if you attempt to access an uninitialized instance variable in Java?
What is the role of 'this' in the BankAccount class constructor?
What is the role of 'this' in the BankAccount class constructor?
In Java, how are instance variables in instance methods related to the calling object?
In Java, how are instance variables in instance methods related to the calling object?