• HOME
  • QUIZ
  • CONTACT US
EXAMIANS
  • COMPUTER
  • CURRENT AFFAIRS
  • ENGINEERING
    • Chemical Engineering
    • Civil Engineering
    • Computer Engineering
    • Electrical Engineering
    • Mechanical Engineering
  • ENGLISH GRAMMAR
  • GK
  • GUJARATI MCQ

JAVA Constructors and Methods

JAVA Constructors and Methods
public class Test { }What is the prototype of the default constructor?

public Test( )
public Test(void)
Test( )
None of these
Test(void)

ANSWER DOWNLOAD EXAMIANS APP

JAVA Constructors and Methods
Determine Output:class A{public static void method(int i){System.out.print("Method 1");}public static int method(String str){System.out.print("Method 2");return 0;}}public class Test{ public static void main(String args[]){A.method(5);}}

Method 2
Compile time error as final method can't be overloaded
Method 1
None of these

ANSWER DOWNLOAD EXAMIANS APP

JAVA Constructors and Methods
Which of the following options is the best for generating random integer 0 or 1?

(int)(Math.random() + 0.5)
(int)(Math.random() + 0.2)
(int)Math.random()
(int)Math.random() + 1

ANSWER DOWNLOAD EXAMIANS APP

JAVA Constructors and Methods
class A{ A(String s){} A(){}}1. class B extends A{2. B(){}3. B(String s){4. super(s);5. }6. void test(){7. // insert code here8. }9. }Which of the below code can be insert at line 7 to make clean compilation ?

None of these
A a = new B();
A a = new A(String s);
All of these
A a = new B(5);

ANSWER DOWNLOAD EXAMIANS APP

JAVA Constructors and Methods
Which of the modifier can't be used for constructors?

protected
static
public
private

ANSWER DOWNLOAD EXAMIANS APP

JAVA Constructors and Methods
What is the output of the program?class Test{ public int display(int x, int y){ return ("The sum of x and y is " + x + y); } public static void main(String args[]){ Test test = new Test(); System.out.println(test.display(4,5)); } }

The sum of x and y is 9
The sum of x and y is 45
does not compile
None of these

ANSWER DOWNLOAD EXAMIANS APP
MORE MCQ ON JAVA Constructors and Methods

DOWNLOAD APP

  • APPLE
    from app store
  • ANDROID
    from play store

SEARCH

LOGIN HERE


  • GOOGLE

FIND US

  • 1.70K
    FOLLOW US
  • EXAMIANSSTUDY FOR YOUR DREAMS.
  • SUPPORT :SUPPORT EMAIL ACCOUNT : examians@yahoo.com

OTHER WEBSITES

  • GUJARATI MCQ
  • ACCOUNTIANS

QUICK LINKS

  • HOME
  • QUIZ
  • PRIVACY POLICY
  • DISCLAIMER
  • TERMS & CONDITIONS
  • CONTACT US
↑