The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be:
variable
method
class
0 notes
Subscribe : http://bit.ly/2j0HVAp
App Link: http://bit.ly/2iE62qv
FB : https://www.facebook.com/stsmentor/
0 notes
// Inheritance
class Parent
{
private void jewellery()
{
System.out.println("Private Jwellery");
}
void bmw()
{
System.out.println("Parent BMW"); }
void flat()
{
System.out.println("Parent Flat"); }
}
class Child extends Parent
{
void swift()
{
System.out.println("Child Swift"); }
public static void main(String args[])
{
Parent p1=new Parent();
p1.flat();
p1.bmw();
// p1.swift(); Child c1=new Child();
c1.swift();
c1.flat();
c1.bmw();
c1.jewellery(); }
}
0 notes
Subscribe : http://bit.ly/2j0HVAp
App Link: http://bit.ly/2iE62qv
FB : https://www.facebook.com/stsmentor/
0 notes
Strings, which are widely used in Java programming, are a sequence of characters. In Java programming language, strings are treated as objects. The Javaplatform provides the String class to create and manipulate strings.
0 notes
Let's see the simple example of the Java Scanner class which reads the int, string and double value as an input:
import java.util.Scanner;
class ScannerTest{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter your rollno");
int rollno=sc.nextInt();
0 notes
Subscribe : http://bit.ly/2j0HVAp
App Link: http://bit.ly/2iE62qv
FB : https://www.facebook.com/stsmentor/
0 notes
Constructor in java is a special type of method that is used to initialize the object.
Java constructor is invoked at the time of object creation. It constructs the values i.e. provides data for the object that is why it is known as constructor.
0 notes
For All the update download STS Mentor Android APP
0 notes
If we decide to choose a three-dimensional array, here's how the array might be declared:
int[][][] colorImage = new int[numRows][numColumns][3];
However, wouldn't it be more effective like this?
int[][][] colorImage = new int[3][numRows][numColumns];
Where 3 is the rgb values, 0 being red, 1 being green, and 2 being blue
0 notes
Array is a collection of similar type of elements that have contiguous memory location.
Java array is an object the contains elements of similar data type. It is a data structure where we store similar elements. We can store only fixed set of elements in a java array.
Array in java is index based, first element of the array is stored at 0 index.
0 notes
do {
// Statements
}while(Boolean_expression);
while(Boolean_expression) {
// Statements
}
0 notes
Loops:
1st. for Loop
2nd. While Loop
3rd. Do While Loop
4th. for each loop
0 notes
Java array is an object the contains elements of similar data type. It is a data structure where we store similar elements. We can store only fixed set of elements in a java array.
0 notes
Control statements
The Java if statement is used to test the condition. It checks boolean condition: true or false. There are various types of if statement in java.
o if statement
o if-else statement
o nested if statement
o if-else-if ladder
Java IF Statement
The Java if statement tests the condition. It executes the if block if condition is true.
0 notes
Internals of Java Program
class Sachtech
{
public static void main(String args[])
{
System.out.println("AASAAN HAI!!!!!!!!");
}
}
Sachtech: Name of the Class and According to the java standard first letter should be capital
but we can use first letter small or capital but we need to follow the java standard.
public: it's Accessspecifier and as per the name public means accessible from anywhere
in real lyf means "public sab janti h" because main function called by the JVM and JVM called main function from
the outside program that's why main function will always public.
static: static represent the class and Non static always represent to class and static used with the main function because before creating an object we
want to call main function that's we used static keyword.
void: void synonym empty that's why void is a non returning data type.
main: main is a function name.
String args[]: Why we used String array in the main function argument because java takes the input in the
form of an array and we will see example when we will do command line argument.
System: System is a Final class in java and first letter is capital and System class doesn’t provide any public constructors,
so we can’t instantiate this class (for argument sake, we can instantiate it using Java Reflection Api
out: out is a instance of PrintStream and declared in the System class.
Here declare out in the System class
public final static PrintStream out = null;
println: println is a method of the PrintStream class.
Steps to Run java program
First compile:
Javac: java compiler converts source code into byte code
Syntax: javac ClassName.java
javac sachtech.java
Then run
Jvm converts byte code into executable code.
Syntax
Java ClassNAme
0 notes
An entity that has state and behavior is known as an object
0 notes