Computer Science, asked by mahimarupa9515, 10 months ago

Write Java statement to create an object mp3 of class audio

Answers

Answered by pesh20gathoni
4

Answer:

mp3 = new Audio();

Explanation:

In Java we use 'new' (case sensitive) keyword to create an object of any class.

There are different way to create objects in Java.

1. Use of 'new' Keyword :

Syntax :

object_name = new class_name();

Example:

mp3 = new audio();

where,

mp3 is an object type of variable.

new is keyword in Java.

Audio() is an class constructor of class Audio.

2. Use of New Instance :

Syntax:

Class Object = Class.forName();  

Class_name obj = (Class)Object.newInstance();

Example:

Class audio = Class.forName("New Instance");  

           Audio obj =  (Audio) audio.newInstance();

Where,

mp3 is an object type of variable.

new is Java keyword.

Audio() is an class constructor of class Audio.

Similar questions