Showing posts with label java tutorial. Show all posts
Showing posts with label java tutorial. Show all posts

Sunday, 25 March 2018

What Are The Access Specifiers/Modifiers In Java || Learn Java In Hindi



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




Access Modifiers in java
There are
two types of modifiers in java: access modifiers and non-access
modifiers.
The access
modifiers in java specifies accessibility (scope) of a data member, method,
constructor or class.
There are 4
types of java access modifiers:
  1. private
  2. default
  3. protected
  4. public
There are
many non-access modifiers such as static, abstract, synchronized, native,
volatile, transient etc. Here, we will learn access modifiers.

Source Codes

-------------------------

A.java

public class A
{
public void m1()
{
System.out.println("public : m1 method");
}
protected void m2()
{
System.out.println("protected : m2 method");
}
void m3() // default - no access
{
System.out.println("no access : m3 method");
}
private void m4()
{
System.out.println("private : m4 method");
}
void call1()
{
m1();
m2();
m3();
m4();
}
}

class test
{
public static void main(String args[])
{
A a1 = new A();
a1.call1();
}
}


B.java


class B extends A
{
void call2()
{
// m4(); // private method can't be accessed here outside the class
// rest methods can be accessed easily here
m1();
m2();
m3();
}
}

class test1
{
public static void main(String srags[])
{
B b1 = new B();
b1.call2();
}
}

C.java


class C
{
void call3()
{
new A().m1();
new A().m2();
new A().m3();
}
}
class test2
{
public static void main(String args[])
{
C c1 = new C();
c1.call3();
}
}

Wednesday, 14 February 2018

What Is The Difference Between Object And Reference In Java || Learn Jav...


Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.




Source Code

--------------------------------

class Student

{
int roll;
String name;
String course;
Student(){}
Student(int roll, String name, String course)
{
this.roll=roll;
this.name=name;
this.course=course;
}
void display()
{
System.out.println("Name : "+name+" Roll : "+roll+" Course : "+course);
}
}
public class OvsR
{
public static void main(String args[])
{
Student ss = new Student();
ss.display();
Student ss1 = new Student(3,"Akram","MCA"); // ss1 holds the base address
ss1.display();
new Student(); // orphan reference
}
}
--------------------------

Description
--------------
What Is The Difference Between Object And Reference In Java.
Difference between object & object reference in java.
The video looks at what an object is and how to create one in Java.  It defines the terms memory reference,instantiation, class and object.It also looks at the syntax for creating an object.

Sunday, 28 January 2018

Beginning With Java Programming || Requirements To Write Java Programs |...


In this video, we guide you through the essential steps to start your journey with Java programming, focusing on setting up the class paths correctly. Understanding how to configure class paths is crucial for compiling and running Java programs, especially when dealing with multiple libraries and external dependencies.

We begin by explaining what a class path is and why it's important in the Java environment. Next, we walk you through the process of setting class paths on different operating systems, including Windows, macOS, and Linux. You'll learn how to configure the CLASSPATH variable, how to include multiple directories or JAR files, and how to troubleshoot common issues related to class paths.

This tutorial is perfect for beginners who are just starting with Java and need a solid foundation to ensure their development environment is set up correctly. By the end of this video, you’ll be able to confidently set and manage class paths, paving the way for smooth Java programming and development.

Java programming, setting class paths, Java classpath setup, Java for beginners, configure CLASSPATH Java, Java environment setup, Java development tutorial, Java class paths explained, Java basics, Java programming setup

Start Writing Programs in Java.

You need JDK (Java Development Kit)(Any version)(Latest is 1.9) and you need to set class path.

In this Video I have explained these two points.

You Should watch this if you are a programmer.

Saturday, 27 January 2018

A Simple Java Code To Open Notepad || Java Tricks


In this video, we demonstrate a simple yet powerful Java trick: how to write a Java code that opens Notepad directly from your application. Whether you're a beginner or an experienced developer, this tutorial will show you how to use Java's Runtime class to interact with your operating system and launch applications like Notepad with just a few lines of code.

We start by explaining the basics of the Runtime class and how it allows Java applications to execute system commands. Then, we walk you through writing a short and effective Java program that opens Notepad on your computer. This tutorial is a great way to expand your Java skills and understand how to leverage the language to interact with the system.

By the end of this video, you'll have a working Java program that opens Notepad, and you'll have learned a useful trick that can be applied to launching other applications or executing system commands. This tutorial is perfect for Java developers looking to explore system-level programming and discover new ways to use Java in their projects.

Java code, open Notepad Java, Java tricks, Java Runtime class, simple Java program, launch applications Java, Java programming tutorial, Java for beginners, Java system commands, Notepad with Java

Source Code

import java.io.IOException;

import java.util.*;

class Notepad

{

public static void main(String args[])

{

Runtime rs=Runtime.getRuntime();

try

{

rs.exec("notepad");

}

catch(IOException e)

{

System.out.println(e);

}

}



}