Menu
Question Index
...

Define a Mobile class with member variables model, numberOfSims, memory and hasCamera. There respective data types are String, int, double and boolean. Also define a constructor which initializes these variables using the passed parameters.



class MobileTester
{
    public static void main(String s[])
    {
        Mobile mobile = new Mobile("Samsung Wave", 2, 1024.0, true);
        
        System.out.print(mobile.model + " has " + mobile.numberOfSims + " sims and has a memory of " + mobile.memory + " MB.");
        System.out.println(mobile.hasCamera ? " It has a camera." : " It has no camera.");

    }



}
class Mobile
{
}

Doubts

Problems

Topic: Create Objects Using Constructors In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App