More on Classes Objects Methods in Java OOPS

In this tutorial, you will learn the Object Oriented Java programming Concepts.

You will learn more about classes, objects, methods, how to create and use them, what is their advantages in detail with example.

Source code for this video tutorial

Code for Student.java

package oops;

public class Student {
 String name = "noname";
 int rollno =0 ;
 int age = 0;
 
 void introduce(){
  System.out.println("my name is "+name);
  System.out.println("my rollno is "+rollno);
  System.out.println("my age is "+age);
 }
 
 void sayNumbers(int start, int end){
  int counter;
  for(counter = start; counter <=end; counter++){
   System.out.println(counter);
  }
 }
 
 boolean hasGirlFriend(){
  return true;
 }
 
}

Code for Tutorials.java

package oops;

public class Tutorials {

 public static void main(String[] args) {
  
  Student anil = new Student();
  anil.name = "Anil Shetty";
  anil.rollno = 1;
  anil.age = 24;
  
  
 // Student andy = new Student();
  
  anil.introduce();
  anil.sayNumbers(2, 10);
  
   
  if(anil.hasGirlFriend()){
   System.out.println("Anil has girlfriend");
  }else{
   System.out.println("Anil has no girlfriend");
  }
  
  //andy.introduce();
 }

}