Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Ruby Online

# Hello World Program in Ruby
puts "Hello World!";

$global_variable = 10000
class Student
    
    @@college_name = "Eastern Illinois University"
    
    def initialize(id, name, course)
        @stu_id = id
        @stu_name = name
        @stu_course = course
    end
    
    def display_student_details
        
        puts "College Name = #@@college_name"
        puts "student id   = #@stu_id"
        puts "student name = #@stu_name"
        puts "Student course = #@stu_course"
        puts "Global Variable = #$global_variable"
    end
end

# creating object for Sutdent class

object1 = Student.new("283560", "shravan", "Technology")
object1.display_student_details

object2 = Student.new("283560", "Divya", "Technology")
object2.display_student_details

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.