• 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
What will be the return type of a method that not returns any value?

None of these
int
double
void

ANSWER DOWNLOAD EXAMIANS APP

JAVA Constructors and Methods
Determine output:public class Test{ public static void main(String args[]){ MyClass obj = new MyClass(); obj.val = 1; obj.call(obj); System.out.println(obj.val); }}class MyClass{ public int val; public void call(MyClass ref){ ref.val++; }}

2
1
3
Compilation Error
None of these

ANSWER DOWNLOAD EXAMIANS APP

JAVA Constructors and Methods
What is the expected output?class Animal {Animal() {System.out.println("Animal");}}class Wild extends Animal{Wild() {System.out.println("Wild");super();}}public class Test {public static void main(String args[]) {Wild wild = new Wild();}}

Animal Wild
Wild Animal
Compilation Error
Runtime Exception

ANSWER DOWNLOAD EXAMIANS APP

JAVA Constructors and Methods
public class MyClass{ }For the above class(MyClass) what is the correct way of declaring constructor?

public MyClass(){}
public MyClass(void){}
MyClass(){}
1 and 3
MyClass(void) {}

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)); } }

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

ANSWER DOWNLOAD EXAMIANS APP

JAVA Constructors and Methods
What is the output of the above program ?class Num { Num(double x ){ System.out.println( x ) ; } }public class Test extends Num { public static void main(String[] args){ Num num = new Num( 2 ) ; } }

0
Compile time error
None of these
2.0

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
↑