0% found this document useful (0 votes)
3 views1 page

Java Classes Objects Summary

Uploaded by

chandrakant More
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Java Classes Objects Summary

Uploaded by

chandrakant More
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java: Classes, Objects & Fundamentals 1.

Summary Introduction Java is an object-oriented language


where programs are built using classes and objects. Java Class Libraries Java provides built-in
packages such as [Link], [Link], [Link], and [Link]. Development Environment 1) Write
code (.java) 2) Compile (javac) 3) Run on JVM. Memory Concepts Stack stores local variables; Heap
stores objects; Method area stores class structures. Arithmetic Java supports +, -, *, /, % operators.
Classes, Objects & Methods Classes contain methods and instance variables. Objects are created
using new. Constructors Used to initialize objects automatically. Control Statements Includes if, if-else,
switch, for, while, do-while. Arrays Fixed-size collections storing the same type. 2. One-Page Cheat
Sheet Class Example:
public class Student {
private String name;
public void setName(String n){ name = n; }
}
Create Object: Student s = new Student();
Constructor: public Student(String n){ name = n; }
Array: int[] a = {1,2,3};
If: if(x>0){}
Loop: for(int i=0;i<5;i++){}
3. Practice Questions & Answers Q1. What is an object in Java?
A. An instance of a class. Q2. What is the difference between primitive and reference types?
A. Primitive holds values directly; reference stores an address pointing to an object. Q3. What does a
constructor do?
A. Initializes objects upon creation. Q4. Write an array declaration.
A. int[] nums = new int[5]; Q5. Name two control statements.
A. if, for

You might also like