What is the similarity between a method and a constructor?

1 Answer

Answer :

A: Below are some of the similarities:
1) Both of them are member methods of any class.
2) Both can be parameterised or non-parameterised.
3) Both can be overloaded.

Related questions

Description : What is super constructor?

Last Answer : A: It is a constructor which is used to call the constructor of the super class and hence initialize the data members of the super class from within the sub class.

Description : What is a copy constructor?

Last Answer : A: It is a constructor which takes object as parameter and copies the value of the instance variable of that object to another object (creates a copy of an object).

Description : What is a constructor?

Last Answer : A: It is a member function with the same name as that of a class and is automatically called for initializing the variables of an object.

Description : A ……………. takes a reference to an object of the same class as itself as an argument. A) Reference constructor B) Copy Constructor C) Self Constructor

Last Answer : B) Copy Constructor

Description : Which of the following characteristics of constructor are true. i) They should be declared in the public section. ii) They are invoked automatically when the objects are created. iii) They do not have return type and void also. ... and v C) Only i, iii, iv and v D) All i, ii, iii, iv and v

Last Answer : D) All i, ii, iii, iv and v

Description : Automatic initialization of object is carried out using a special member function called ………… A) Friend B) Casting C) Reference Parameter D) Constructor

Last Answer : D) Constructor

Description : A constructor that accepts no parameters is called the ………………. A) Paramless constructor B) No parameter constructor C) Default constructor D) Argumentless constructor

Last Answer : C) Default constructor

Description : Which of the following, in C++, is inherited in a derived class from base class ? (A) constructor (B) destructor (C) data members (D) virtual methods

Last Answer : (C) data members

Description : Implicit return type of a class constructor is: (A) not of class type itself (B) class type itself (B) a destructor of class type (D) a destructor not of class type 

Last Answer : (B) class type itself

Description : Which one of the following research methods, have the similarity in nature when compared in relation to sample, control and validity of inferences? Options: A) Experimental and Ex Post Faco method B) Historical and Philosophical method C) Survey and Experimental method D) None of the above

Last Answer : B) Historical and Philosophical method 

Description : What is an abstract method?

Last Answer : A: An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon), like this: abstract void point(double x, double y);

Description : Why is the main method static?

Last Answer : A: So that it be available for execution without the need of any object.

Description : Why is the main method public?

Last Answer : A: So that it be accessible to the JVM which begins to execute the program from outside of the class.

Description : What is the function of readLine() method?

Last Answer : A: readLine() method reads a line of text (which you input) and returns the result in the form of a String.

Description : State true of false. i) Public can only be assigned to class ii) Protected protects a statement iii) Protected method is never accessible outside the package iv) Friendly variable may be accessible outside class A) i- ... -false, ii-true, iii-false, iv-false D) i-true, ii-false, iii-false, iv-true

Last Answer : C) i-false, ii-true, iii-false, iv-false

Description : Each method in a java class must have a unique name . A) Not necessary B) True C) False D) None of the above

Last Answer : A) Not necessary

Description : Using which keyword we can access value of the instance variables and class variables of that class inside the method of that class itself. A) super B) final C) this D) either super or this

Last Answer : C) this

Description : A method name myMethod( ) that needs two integer arguments is declared as A) public void myMethod( ); B) public void myMethod(int a, int b); C) public void myMethod(int a, b); D) public int myMethod(a, b);

Last Answer : B) public void myMethod(int a, int

Description : In Java servlet method init( ) is called ..................... times. A) 1 B) 2 C) 0 D) multiple

Last Answer : A) 1

Description : Which method will a web browser call on a new applet? A) main method B) destroy method C) execute method D) init method

Last Answer : D) init method

Description : For execution of DELETE SQL query in JDBC, ............. method must be used. A) executeQuery() B) executeDeleteQuery() C) executeUpdate() D) executeDelete()

Last Answer : C) executeUpdate()

Description : What would happen if "String[]args" is not included as argument in the main method. A) No error B) Compilation error C) Program won't run D) Program exit

Last Answer : C) Program won't run

Description : break statement is used to i) get out of method ii) end aprogram iii) get out of a loop iv) get out of the system A) 1 & 2 B) 1,2 & 3 C) 1 & 3 D) 3

Last Answer : D) 3

Description : A direct method of deadlock prevention is to prevent the occurrence of ………….. A) Mutual exclusion B) Hold and wait C) Circular waits D) No preemption

Last Answer : C) Circular waits

Description : A direct method of deadlock prevention is to prevent the occurrences of ................... A) Mutual exclusion B) Hold and wait C) Circular waits D) No preemption

Last Answer : C) Circular waits

Description : ..................... provides a larger sized of virtual memory but require virtual memory which provides multidimensional memory. A) Paging method B) Segmentation method C) Paging and segmentation method D) None of these

Last Answer : B) Segmentation method

Description : ……………… is a tabular method for describing the logic of the decisions to be taken. A) Decision tables B) Decision tree C) Decision Method D) Decision Data

Last Answer : A) Decision tables

Description : ………………. is responsible for all aspects of data processing, operation research, organization and method, system analysis and design investments. A) Management Services Director B) Data Processing Manager C) Computer Manager D) Both B and C

Last Answer : A) Management Services Director

Description : In general, the binary search method needs no more than ……………. comparisons. A) [log2n]-1 B) [logn]+1 C) [log2n] D) [log2n]+1

Last Answer : D) [log2n]+1

Description : ………………… is preferred method for enforcing data integrity A) Constraints B) Stored Procedure C) Triggers D) Cursors

Last Answer : A) Constraints

Description : ……………. is a preferred method for enforcing data integrity A) Constraints B) Stored procedure C) Triggers D) Cursors

Last Answer : A) Constraints

Description : HSAM stands for ………. A) Hierarchic Sequential Access Method B) Hierarchic Standard Access Method C) Hierarchic Sequential and Method D) Hierarchic Standard and Method

Last Answer : A) Hierarchic Sequential Access Method

Description : A simple cabling method, known as the ……………… topology allows about 30 computers on a maximum cable length of about 600 feet. A) Ring B) Bus C) Star D) Mesh

Last Answer : B) Bus

Description : Which of the following algorithm design technique is used in the quick sort algorithm? a) Dynamic programming b) Backtracking c) Divide-and-conquer d) Greedy method

Last Answer : Which of the following algorithm design technique is used in the quick sort algorithm? a) Dynamic programming b) Backtracking c) Divide-and-conquer d) Greedy method

Description : What is the output of the following code? a={1:"A",2:"B",3:"C"} b={4:"D",5:"E"} a.update(b) print(a) a) {1: ‘A’, 2: ‘B’, 3: ‘C’} b) Method update() doesn’t exist for dictionaries c) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’} d) {4: ‘D’, 5: ‘E’}

Last Answer : c) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’}

Description : What is the output of the following code? a={1:"A",2:"B",3:"C"} print(a.setdefault(3)) a) {1: ‘A’, 2: ‘B’, 3: ‘C’} b) C c) {1: 3, 2: 3, 3: 3} d) No method called setdefault() exists for dictionary

Last Answer : b) C

Description : What is the output of the following code? >>> a=(2,3,4) >>> sum(a,3) a) Too many arguments for sum() method b) The method sum() doesn’t exist for tuples c) 12 d) 9

Last Answer : c) 12

Description : The total transportation cost in an initial basic feasible solution to the following transportation problem using Vogel’s Approximation method is  (A) 76 (B) 80 (C) 90 (D) 96

Last Answer : (B) 80

Description : At any iteration of simplex method, if Δj (Zj – Cj) corresponding to any nonbasic variable Xj is obtained as zero, the solution under the test is (A) Degenerate solution (B) Unbounded solution (C) Alternative solution (D) Optimal solution

Last Answer : (C) Alternative solution

Description : Equivalence partitioning is a .................. method that divides the input domain of a program into classes of data from which test cases can be derived. (A) White-box testing (B) Black-box testing (C) Orthogonal array testing (D) Stress testing

Last Answer : (B) Black-box testing

Description : The syntax of capturing events method for document object is (A) CaptureEvents() (B) CaptureEvents(Orgs eventType) (C) CaptureEvents(eventType) (D) CaptureEvents(eventVal)

Last Answer : (C) CaptureEvents(eventType)

Description : Which of the following statements is not true about disk-arm scheduling algorithms ? (A) SSTF (shortest seek time first) algorithm increases performance of FCFS. (B) The number of requests for disk ... arm movements. (D) SCAN and C-SCAN algorithms are less likely to have a starvation problem.

Last Answer : (B) The number of requests for disk service are not influenced by file allocation method.

Description : Beam-penetration and shadow-mask are the two basic techniques for producing color displays with a CRT. Which of the following is not true ? I. The beam-penetration is used with random scan monitors. II. Shadow-mask is used ... -penetration method. (A) I and II (B) II and III (C) III only (D) IV only

Last Answer : (C) III only

Description : You have to sort a list L, consisting of a sorted list followed by a few ‘random’ elements. Which of the following sorting method would be most suitable for such a task ? (A) Bubble sort (B) Selection sort (C) Quick sort (D) Insertion sort

Last Answer : (D) Insertion sort

Description : Consider the following transportation problem: The initial basic feasible solution of the above transportation problem using Vogel's Approximation Method(VAM) is given below: The solution of the ... degenerate solution (B) is optimum solution (C) needs to improve (D) is infeasible solution

Last Answer : (B) is optimum solution

Description : In the Hungarian method for solving assignment problem, an optimal assignment requires that the maximum number of lines that can be drawn through squares with zero opportunity cost be equal to the number of: (A) rows or columns (B) rows+columns (C) rows+columns-1 (D) rows+columns+1

Last Answer : (A) rows or columns

Description : In ............ allocation method for disk block allocation in a file system, insertion and deletion of blocks in a file is easy. (A) Index (B) Linked (C) Contiguous (D) Bit Map

Last Answer : (B) Linked

Description : The Servlet Response interface enables a servlet to formulate a response for a client using the method ............... (A) void log(Exception e, String s) (B) void destroy() (C) int getServerPort() (D) void setContextType(String Type)

Last Answer : (D) void setContextType(String Type)

Description : In Java, when we implement an interface method, it must be declared as: (A) Private (B) Protected (C) Public (D) Friend

Last Answer : (C) Public

Description : Which one of the following statements is incorrect ? (A) Pareto analysis is a statistical method used for analyzing causes, and is one of the primary tools for quality management. (B) Reliability of ... (D) In white-box testing, the test cases are decided from the specifications or the requirements.

Last Answer : (D) In white-box testing, the test cases are decided from the specifications or the requirements.