The document discusses various Java concepts like overloading and overriding methods, constructors, static blocks, and initializer blocks. It provides code examples to demonstrate that a constructor does not return a value but initializes object fields, a static method can be overridden in a derived class but not overloaded, and an initializer block is used to initialize fields and is called before the constructor.
Inheritance is the mechanism that allows programmers to create new classes from existing class. By using inheritance programmers can re-use code they've already written.
Here we are going to learn why is a good practice to use interfaces and how they are different from abstraction classes. Further more we are going to see how which one of them to use.
Interface in java ,multiple inheritance in java, interface implementationHoneyChintal
multiple inheritance in java, interface implementation, abstraction,
multiple inheritance in java using interface, how to use interface,
how to use java, how to execute a java code
An interface is a reference type in Java. It is similar to the class. It is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. Along with abstract methods, an interface may also contain constants, default methods, static methods, and nested types.
in this tutorial we will discuss about
exception handling in C#
Exception class
creating user-defined exception
throw keyword
finally keyword
with examples'
Inheritance is the mechanism that allows programmers to create new classes from existing class. By using inheritance programmers can re-use code they've already written.
Here we are going to learn why is a good practice to use interfaces and how they are different from abstraction classes. Further more we are going to see how which one of them to use.
Interface in java ,multiple inheritance in java, interface implementationHoneyChintal
multiple inheritance in java, interface implementation, abstraction,
multiple inheritance in java using interface, how to use interface,
how to use java, how to execute a java code
An interface is a reference type in Java. It is similar to the class. It is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. Along with abstract methods, an interface may also contain constants, default methods, static methods, and nested types.
in this tutorial we will discuss about
exception handling in C#
Exception class
creating user-defined exception
throw keyword
finally keyword
with examples'
Object Oriented Programming_Chapter 3 (Two Lectures)
1- Let’s think on Inheritance
2- Let’s focus on Superclass’s Constructor
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
Introduction of Object Oriented Programming Language using Java. .pptxPoonam60376
The slide contains the Introduction of Object Oriented Programming Language using Java. It covers basics of OOP, Inheritance,Polymorphism, Exception etc.
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Udayan Khattry
Assess your preparation with these Practice Test Questions with Explanation. Questions are Extracted from Highest Rated Course on Udemy which has helped a lot of students to pass the exam with good score.
500+ multiple choice questions with explanation to assess Oracle Certified Associate, Java SE 8 Programmer II preparation.
Highest Rated course on UDEMY
Read the students success stories at:
https://udayankhattry.com/ocp/
Enroll now to receive maximum discount on the course ie. for just $9.99 or ₹640.00, click the link below- https://www.udemy.com/java-ocp/?couponCode=UDAYANKHATTRY.COM
To avail maximum discount on all courses visit: www.udayankhattry.com
Java Universal super class java.lang.Object is discussed comprehensively with code snippets.
Also covers:
a) Why we need inheritance and dynamic method dispatch
b) Need of a universal parent
c) Delegation and proxies
d) toString(), clone(), equals(), notify()
OCJP Samples Questions: Exceptions and assertionsHari kiran G
Are you a Java enthusiast and preparing for Java 8 certification exam (OCP Java SE 8)? Try out this Quiz on Exceptions and Assertions
This quiz has answers with detailed explanation.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
2. First Program
2
Jainul A. Musani
Class test1
{
public static void main(String s[])
{
System.out.println(“Good Morning…”);
}
}
3. Can we overload main method?
3
Jainul A. Musani
Normal Overloading
sum(int a, int b)
sum(double a, double b)
sum(int a, int b, int c)
4. Can we overload main method?
4
Jainul A. Musani
public class MyMainOverload
{
public static void main(Integer args)
{ S.o.p(“int Args in main() method ");
}
public static void main(char args)
{ S.o.p(“char Args main() method ");
}
//Original main() method
public static void main(String[] args)
{ S.o.p("Original main() method ");
}
}
5. Can we overload main method?
5
Jainul A. Musani
public class MyMainOverload
{
public static void main(Integer args)
{ S.o.p(“int Args in main() method ");
}
public static void main(char args)
{ S.o.p(“char Args main() method ");
}
//Original main() method
public static void main(String[] args)
{ S.o.p("Original main() method ");
}
new MyMainOverload();
new MyMainOverload.main(10);
new MyMainOverload.main(‘Z’);
}
6. Constructor returns a value but, what?
6
Jainul A. Musani
Constructor Types:
1. Default Constructor
2. Parameterized Constructor
Java constructor doesn't return any specific value,
which can directly affect the code.
A constructor is called by the memory allocation and
object initialization code at runtime.
The Constructor is more responsible for assigning
the initial values to the data members of the class.
A constructor returns the instance created by the new
keyword in our
7. Constructor returns a value but, what?
7
Jainul A. Musani
public class Emp {
int EmpNo;
String EmpName;
Emp(){
System.out.println("I am a Emp-Constructor");
}
public static void main(String[] args) {
Emp e1 = new Emp();
System. out. println(e1); // Emp@4dc63996
}
}
8. Singleton Class using private constructor
8
Jainul A. Musani
To create a class that can be instantiated
only once at a time.
Steps
1.Define the class constructor as private.
2.Create a static method that returns the object of
this class.
9. Singleton Class using private constructor
9
Jainul A. Musani
public class CAR{
private static CAR bmw = null;
public String msg;
private CAR() {}
public static CAR getAcar() {
If (bmw == null){
bmw = new CAR();
}
return bmw;
}
10. Singleton Class using private constructor
10
Jainul A. Musani
public static void main(String[] args) {
CAR mycar = CAR.getAcar();
mycar.msg = “My BMW is no.1";
CAR mycar2 = CAR.getAcar();
mycar2.msg = “My New BMW No.2";
CAR mycar3 = CAR.getAcar();
mycar3.msg = “My Vintage Car No. 3";
System.out.println(“Car 1
: "+mycar.msg);
System.out.println(“Car 2 : "+
mycar2.msg);
System.out.println(“Car 3 : "+
mycar3.msg);
11. Singleton Class using private constructor
11
Jainul A. Musani
OUTPUT:
Car 1 : My Vintage Car No. 3
Car 2 : My Vintage Car No. 3
Car 3 : My Vintage Car No. 3
12. Can constructor be private in Java?
12
Jainul A. Musani
Java allows to declare a constructor as
private.
Declare a constructor private by using
the private access specifier.
Note that if a constructor is declared
private, we are not able to create an
object of the class. Instead, we can use
this private constructor in Singleton
Design Pattern.
13. Can we create a program without main method?
13
Jainul A. Musani
Using STATIC Block:
class A{
static{
System.out.println("class without a main method");
System.exit(0);
}
}
This is valid till the Java 6 version. From Java 7 onwards the
compiler JVM will give you error message – main() method
missing.
14. Can main() method as Non-Static in java?
14
Jainul A. Musani
No.
Error will display
15. Multiple inheritance is not supported in java?
15
Jainul A. Musani
Ambiguity in the derived class.
ABC extends String – toString() method
override,
FLYER - makeFly() method
BIRD extends ABC, FLYER – doAnything()
method
ObjBird – can’t call the methods available in
ABC class (i.e. toString()) it will not able to
decide from which method it should invoke
from ABC or from FLYER?
16. Can We Override static method?
16
Jainul A. Musani
Overload – YES
Override – NO
BUT,
the method is written in derived class
Override – YES :
17. Can We Override static method?
17
Jainul A. Musani
Overload
public class Test {
public static void foo() {
System.out.println("Test.foo() called ");
}
public static void foo(int a) {
System.out.println("Test.foo(int) called ");
}
public static void main(String args[])
{
Test.foo();
Test.foo(10);
}
}
18. Can We Override static method?
18
Jainul A. Musani
Override
public class Test {
public static void foo() {
System.out.println("Test.foo() called ");
}
public static void foo() {// Compiler Error: cannot redefine foo()
System.out.println("Test.foo() called ");
}
public static void main(String args[])
{
Test.foo();
Test.foo(10);
}
}
19. Can We Override static method?
19
Jainul A. Musani
In Derived Class
class Base {
public static void display() {
System.out.println("Static or class
method from Base");
}
public void print() {
System.out.println("Non-static or Instance
method from Base");
}
}
20. Can We Override static method?
20
Jainul A. Musani
In Derived Class
class Derived extends Base {
public static void display() {
System.out.println("Static or class
method from Derived");
}
System.out.println("Non-static or Instance
method from Derived");
}
}
21. public class Test {
public static void main(String args[ ]) {
Base obj1 = new Derived();
obj1.display();
obj1.print();
}
}
Can We Override static method?
21
Jainul A. Musani
Static or class method from Base
Non-static or Instance method from
Derived
Output
In Derived Class
22. What is covariant return type?
22
Jainul A. Musani
class A1
{
A1 foo() {
return this;
}
void print(){
System.out.println(“Inside class A1”);
}
}
1
23. What is covariant return type?
23
Jainul A. Musani
class A2 extends A1
{
@Override
A2 foo() {
return this;
}
void print(){
System.out.println(“Inside class A2”);
}
}
2
24. What is covariant return type?
24
Jainul A. Musani
class A3 extends A2
{
@Override
A2 foo() {
return this;
}
@Override
void print(){
System.out.println(“Inside class A3”);
}
}
3
25. What is covariant return type?
25
Jainul A. Musani
public class CovariatEx
{
public static void main(String args[]) {
A1 obj1 = new A1();
obj1.foo().print() ‘Inside class A1’
A2 obj2 = new A2();
obj2.foo().print() ‘Inside class A2’
A3 obj3 = new A3();
obj3.foo().print() ‘Inside class A3’
}
}
4
26. What is covariant return type?
26
Jainul A. Musani
public class CovariatEx
{
public static void main(String args[]) {
A1 obj1 = new A1();
obj1.foo().print() ‘Inside class A1’
A2 obj2 = new A2();
((A2)obj2).foo().print() ‘Inside class A2’
A3 obj3 = new A3();
((A3)obj3).foo().print() ‘Inside class A3’
}
}
5
27. Why use instance initializer block?
27
Jainul A. Musani
static block v/s initializer block
initializer v/s constructor
super() calls only constructor not
initializer block but when before
constructor initializer block always calls.
So indirectly super() calls initializer
block.
28. initializer block
28
Jainul A. Musani
public class Bike
{
int speed;
Bike(){ S.o.p(“Bike Speed is : “ + speed); }
{ // initializer block
speed = 100;
}
public static void main(String args[]) {
Bike b1 = new Bike();
Bike b2 = new Bike();
}
}