Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

true or false: 1. IN JAVA, THE REFERENCE this IS USED TO REFER TO ONLY THE INSTA

ID: 3542951 • Letter: T

Question

true or false:

1. IN JAVA, THE REFERENCE this IS USED TO REFER TO ONLY THE INSTANCE VARIABLES, NOT THE METHODS OF A CLAS.

2 THE DEFAULT DEFINITION OF THE METHOD toString is it creates a string that is the name of the package, followed by the name of the class, followed by the hash code of the code.

3. ADT's hide the implementation details of operations from users.

4. we can use the delational operator = = to determined whether 2 different objects of the same class contain the same data

5. In static method, you may use the THIS parameter either explicitly or implicitly

6. Java source code that contains a class with an inner class, when compiled, will not produce a separate .class file for the inner class.


q's multiple choice

7. within the definition of a constructor for a class, you can use (a) _______ as a name for another constructor in the same class.

a) constructor with appropiate parameter. b) reference variable. c) public static variable. d) this.

8. A _______ states what is assumed to be true when the method is called.

a) prescript.  b) postscript. c) precodition. d) postcondition.

Explanation / Answer

1.ans:False

The reference variables can be used to acess both the methods as well as the instance variables,

for example:

class A

{

int d=5;//instance variable

void add(int a,int b)//class method

{

        System.out.println(a+b);

}

public static vouid main(String args[])

{

           A ob=new A();//here ob is reference variable

System.out.println(d);//acessing the instance variable

A.add(10,5);//acessing the calss method

}

}

          


2 Ans : False

Every class in the java inherits from Object class implicitly or explicitly

If you have created a class with out toString() method then the toString method of object class is called and it returns

a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object.


3.Ans : True SInce the methods are declared in one class and defination is given in the other class.


4.Ans False , the == operator only specifies whether the two objects of same class but it may or may not contain the same data


5. Ans: false

The static methods does not allow the use of THIS keyword either explicitly or implicitly

6.: True

the seperate file is not created for inner class



7. a) constructor with appropiate parameter

8. c) precodition.