Skip to main content

Posts

Showing posts with the label Class 12th

ads1

class 12th Chapter-8 Classes and object in Java.

    A class contains both data (referred to as attributes), and program cod e Creating objects Creating an object from a class requires the following steps : Declaration : A variable (reference variable) name of type class is declared with syntax <class name> <variable name> • Instantiation : Keyword new is used to create the object by allocating memory • Initialization: Constructor (a special type of method) is called to initialize the newly created Using new keyword, we can create an object. Operator new allocates the memory for an object and returns the address When an object is created, in addition to allocating memory, a special method called 'constructor is executed to perform initial task. rl = new Room(); Here, parentheses are important; In object-oriented programming (OOP) languages, creating an object is also called object instantiation. An instance for an object is created by allocating memory to store the data for that object. Instance variables define the a

JAVA Program || Write a Java program to enter temperature in Fahrenheit and convert to Celsius.

                                                 Write a Java program to enter temperature in Fahrenheit and convert to Celsius   (Hint) C= (f-32)*9/5 Static :-  class Celsius {     public static void main(String args[])     {         Double fah = 205.0;         Double cel;         cel = (fah - 32)*5/9;         System.out.println("The temperature in Celsius is :- "+cel);     } } Output :-    Dynamic  import java.util.*; class Celsius {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         System.out.println("Enter the Temperature in Faherenheit :-");         double fah = in.nextDouble();         double cel = (fah-32)*5/9;         System.out.println("The temperature in Celsius is :- "+cel);     } } Output :-         

ads2