SlideShare a Scribd company logo
JAVA Solution 
2010
Short Answer Question 
1. What is thread 
• Is a sequential flow of control in a process 
2. What is the use of finally keyword 
• Contains code to free the resource like file 
handling, database connection etc 
3. Which classes are used to read and write 
bytes to file 
• PrintStream (Write) 
• Scanner (Read)
Short Answer Question… 
4. Define interface 
5. What is skeleton in RMI 
ProductImpl_Skel (A skeleton class that is located 
on the server (needed prior to JDK 1.2)) 
Server side stub is refered to as a skeleton 
6.Why is java called architecturally neutral language 
Platform Independent
Short Answer Question… 
7. Define package 
8. Why is main function defined as static 
To call by class name i.e. ClassName.main() 
9. List the access specifier in java 
Private, Public, Protected 
10. Which function is used in servlet when data 
is using get method 
doGet()
Long Answer Question 
1. What is nested class? Explain with suitable example. 
• Class inside Class (Inner Class) 
class A 
{ 
public int temp; 
public static class B 
{ 
public int b; 
} 
public void test() 
{ 
B b1 = new B(); 
b1.b = 10; 
System.out.println(b1.b); 
} 
} 
class TestFirstInnerClass 
{ 
public static void main(String arg[]) 
{ 
A a1 = new A(); 
A.B binner = new A.B(); 
binner.b = 20; 
System.out.println(binner.b); 
a1.test(); 
} 
}
Long Answer Question… 
2. Java code to connect database 
class DataBase 
{ 
public static void main(String agr[]) throws Exception 
{ 
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
Connection conn = DriverManager.getConnection("jdbc:odbc:Library10","",""); 
String str="insert into titles values(1,'java','comuter',3434)"; 
Statement stat = conn.createStatement(); 
stat.executeUpdate(str); 
conn.close(); 
} 
}
Long Answer Question… 
3. RMI and Its Steps 
 Creating Remote Interface 
 Implementing the Remote Interface 
 Creating main server class which register the 
remote object 
 Client consuming the server’s method
Long Answer Question… 
5. AWT (Abstract Windows Toolkit).
CODE… 
public class AWTTest extends Frame{ 
public Label lbl1 = new Label("Enter a number:"); 
public Label lbl2 = new Label("Enter a number:"); 
public TextField fld1 = new TextField(10); 
public TextField fld2 = new TextField(10); 
public Button btn = new Button("OK"); 
public AWTTest() 
{ 
setLayout(new BorderLayout()); 
add(lbl1); 
add(fld1); 
add(lbl2); 
add(fld2); 
add(btn); 
setSize(250, 250); 
setVisible(true); 
} 
public static void main(String arg[]) 
{ 
new AWTTest(); 
} 
}
Long Answer Question… 
6. Event Handling Example
public class EventTest extends JFrame implements ActionListener{ 
public JLabel lbl1 = new JLabel("Enter a number:"); 
public JLabel lbl2 = new JLabel("Enter a number:"); 
public JTextField fld1 = new JTextField(10); 
public JTextField fld2 = new JTextField(10); 
public JTextField fld3 = new JTextField(10); 
public JButton btn = new JButton("OK"); 
public EventTest() 
{ 
setLayout(new FlowLayout()); 
add(lbl1); 
add(fld1); 
add(lbl2); 
add(fld2); 
add(btn); 
add(fld3); 
btn.addActionListener(this); 
setSize(250, 250); 
setVisible(true); 
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
} 
public void actionPerformed(ActionEvent e) 
{ 
int a = Integer.parseInt(fld1.getText()); 
int b = Integer.parseInt(fld2.getText()); 
int c = a + b; 
fld3.setText(String.valueOf(c)); 
} 
public static void main(String arg[]) 
{ 
new EventTest(); 
} 
}
Long Answer Question… 
7. Java Beans 
• A reusable software component that can be manipulated visually in a 
‘builder tool’. (from JavaBean Specification) 
• The JavaBeans API provides a framework for defining reusable, 
embeddable, modular software components 
• Software components written in Java 
• Event Handling
Long Answer Question… 
8. Applet 
 A Java applet is an applet delivered to users in the form of Java bytecode 
 Java applets can be part of a web page and executed by the Java Virtual 
Machine (JVM) in a process separate from the web browser, or run 
in Sun's AppletViewer 
 Give Example 
9. Final Keyword 
 To make the constant 
 To stop the class from being inherited 
 Give Example
2011 
Short Answer Question 
1. What is bytecode? 
 Java bytecode is the form of instructions that the Java virtual 
machine executes 
2. What is parameter marshalling? 
 Transfer of parameters (or marshalling) is done by the RMI 
3. What is synchronization? 
 Synchronization is a feature by which only one thread can access a resource in a 
particular time of instance. 
 No other thread can interrupt for that resource
Short Answer Question… 
4. What is an exception? 
 An exception is an event, which occurs during the execution of a program, that 
disrupts the normal flow of the program's instructions 
 Example :- NullPointerException, DivideByZeroException, dereference of a null 
pointer, out-of-bounds array access, attempt to open a non-existent file for reading 
5. How do you create a new package in java? 
package <package_name> 
6. Differentiate between AWT and Swing 
Heavyweight vs Lightweight
Short Answer Question… 
8. How does java support runtime 
polymorphism? 
 Function Overriding 
9. Why are character streams more convenient 
for handling in java? 
 Text-based I/O works with streams of human-readable characters, while data-based 
I/O works with streams of binary data 
10. Interface and abstract class 
 All methods of interface are by default abstract 
 Only abstract method of abstract class are abstract 
 Examples
Long Answer Questions 
1. Event handling with addition and subtraction 
Example 
2. Thread priority 
 
Every Java thread has a priority that helps the operating system determine the 
order in which threads are scheduled 
 ThreadObject.setPriority(num) 
 MIN (1) and MAX(10) NORMAL(5) 
3. Socket 
 Programs manage each client connection with a Socket object 
 Socket allows the server to interact with the client 
 Example
Long Answer Questions… 
4. Prepared Statement
2012 
Short Answer Question 
1. What is SQLException 
If the DriverManager cannot connect to the database 
2. Are the java always platform independent? 
No if java has called the native file 
3. States of a thread in java 
New, Blocked, Running, Wait, Runnable 
4. Name the event generated by the button 
ActionEvent, ItemEvent (by list items) 
5. Use of import 
To import the API of java
Short Answer Question… 
6. rebind() method 
Register the server object in RMI 
7. read() method 
To read the buffer string

More Related Content

PPTX
What is Java? Presentation On Introduction To Core Java By PSK Technologies
PPTX
Unit1 introduction to Java
PPT
Java interview-questions-and-answers
PPT
8 most expected java interview questions
PPT
Hibernate introduction
PDF
50+ java interview questions
PDF
Java Interview Questions by NageswaraRao
DOCX
Hibernate3 q&a
What is Java? Presentation On Introduction To Core Java By PSK Technologies
Unit1 introduction to Java
Java interview-questions-and-answers
8 most expected java interview questions
Hibernate introduction
50+ java interview questions
Java Interview Questions by NageswaraRao
Hibernate3 q&a

What's hot (17)

PDF
Java interview questions
PPTX
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
PDF
Java questions for interview
PDF
Java Interview Questions
PPTX
Lecture - 1 introduction to java
PPTX
Dev labs alliance top 20 basic java interview question for sdet
DOCX
Java interview questions and answers for cognizant By Data Council Pune
PDF
Core java interview questions
PPTX
Java training in delhi
PDF
Bea weblogic job_interview_preparation_guide
DOCX
Threadnotes
PPT
Basic java part_ii
PDF
Java Course 13: JDBC & Logging
PDF
Multi threading
PDF
Best interview questions
PDF
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...
PPT
What is Java Technology (An introduction with comparision of .net coding)
Java interview questions
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java questions for interview
Java Interview Questions
Lecture - 1 introduction to java
Dev labs alliance top 20 basic java interview question for sdet
Java interview questions and answers for cognizant By Data Council Pune
Core java interview questions
Java training in delhi
Bea weblogic job_interview_preparation_guide
Threadnotes
Basic java part_ii
Java Course 13: JDBC & Logging
Multi threading
Best interview questions
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...
What is Java Technology (An introduction with comparision of .net coding)
Ad

Similar to Java solution (20)

PDF
Java Multithreading Interview Questions PDF By ScholarHat
PDF
A CASE STUDY JAVA IS SECURE PROGRAMMING LANGUAGE
PPTX
Java se7 features
PPTX
brief introduction to core java programming.pptx
PPTX
Clojure Fundamentals Course For Beginners
PDF
best java training center in chennai
PPTX
Multithreading and concurrency in android
ODP
What's new in Java EE 6
PPT
J2EEvs.NET
PDF
Example Of Import Java
PDF
Java programming material for beginners by Nithin, VVCE, Mysuru
PPTX
OOP with Java
PPT
Shopzilla On Concurrency
PPT
Java2 platform
PPTX
Advance java prasentation
PPTX
Java/Servlet/JSP/JDBC
PPT
Java basic
PPTX
2 22CA026_Advance Java Programming_Data types and Operators.pptx
Java Multithreading Interview Questions PDF By ScholarHat
A CASE STUDY JAVA IS SECURE PROGRAMMING LANGUAGE
Java se7 features
brief introduction to core java programming.pptx
Clojure Fundamentals Course For Beginners
best java training center in chennai
Multithreading and concurrency in android
What's new in Java EE 6
J2EEvs.NET
Example Of Import Java
Java programming material for beginners by Nithin, VVCE, Mysuru
OOP with Java
Shopzilla On Concurrency
Java2 platform
Advance java prasentation
Java/Servlet/JSP/JDBC
Java basic
2 22CA026_Advance Java Programming_Data types and Operators.pptx
Ad

More from 1Arun_Pandey (7)

PPTX
Sorfware engineering presentation (software testing)
PPTX
DISTRIBUTION
PPTX
Extended relational algebra
PPTX
Database architecture
PPTX
Planning
PPTX
Data communication principle
PPTX
Project on Hotel Management System
Sorfware engineering presentation (software testing)
DISTRIBUTION
Extended relational algebra
Database architecture
Planning
Data communication principle
Project on Hotel Management System

Recently uploaded (20)

PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Institutional Correction lecture only . . .
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Cell Structure & Organelles in detailed.
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Insiders guide to clinical Medicine.pdf
Institutional Correction lecture only . . .
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Complications of Minimal Access Surgery at WLH
Renaissance Architecture: A Journey from Faith to Humanism
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Final Presentation General Medicine 03-08-2024.pptx
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPH.pptx obstetrics and gynecology in nursing
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
RMMM.pdf make it easy to upload and study
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Cell Structure & Organelles in detailed.
school management -TNTEU- B.Ed., Semester II Unit 1.pptx

Java solution

  • 2. Short Answer Question 1. What is thread • Is a sequential flow of control in a process 2. What is the use of finally keyword • Contains code to free the resource like file handling, database connection etc 3. Which classes are used to read and write bytes to file • PrintStream (Write) • Scanner (Read)
  • 3. Short Answer Question… 4. Define interface 5. What is skeleton in RMI ProductImpl_Skel (A skeleton class that is located on the server (needed prior to JDK 1.2)) Server side stub is refered to as a skeleton 6.Why is java called architecturally neutral language Platform Independent
  • 4. Short Answer Question… 7. Define package 8. Why is main function defined as static To call by class name i.e. ClassName.main() 9. List the access specifier in java Private, Public, Protected 10. Which function is used in servlet when data is using get method doGet()
  • 5. Long Answer Question 1. What is nested class? Explain with suitable example. • Class inside Class (Inner Class) class A { public int temp; public static class B { public int b; } public void test() { B b1 = new B(); b1.b = 10; System.out.println(b1.b); } } class TestFirstInnerClass { public static void main(String arg[]) { A a1 = new A(); A.B binner = new A.B(); binner.b = 20; System.out.println(binner.b); a1.test(); } }
  • 6. Long Answer Question… 2. Java code to connect database class DataBase { public static void main(String agr[]) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:odbc:Library10","",""); String str="insert into titles values(1,'java','comuter',3434)"; Statement stat = conn.createStatement(); stat.executeUpdate(str); conn.close(); } }
  • 7. Long Answer Question… 3. RMI and Its Steps  Creating Remote Interface  Implementing the Remote Interface  Creating main server class which register the remote object  Client consuming the server’s method
  • 8. Long Answer Question… 5. AWT (Abstract Windows Toolkit).
  • 9. CODE… public class AWTTest extends Frame{ public Label lbl1 = new Label("Enter a number:"); public Label lbl2 = new Label("Enter a number:"); public TextField fld1 = new TextField(10); public TextField fld2 = new TextField(10); public Button btn = new Button("OK"); public AWTTest() { setLayout(new BorderLayout()); add(lbl1); add(fld1); add(lbl2); add(fld2); add(btn); setSize(250, 250); setVisible(true); } public static void main(String arg[]) { new AWTTest(); } }
  • 10. Long Answer Question… 6. Event Handling Example
  • 11. public class EventTest extends JFrame implements ActionListener{ public JLabel lbl1 = new JLabel("Enter a number:"); public JLabel lbl2 = new JLabel("Enter a number:"); public JTextField fld1 = new JTextField(10); public JTextField fld2 = new JTextField(10); public JTextField fld3 = new JTextField(10); public JButton btn = new JButton("OK"); public EventTest() { setLayout(new FlowLayout()); add(lbl1); add(fld1); add(lbl2); add(fld2); add(btn); add(fld3); btn.addActionListener(this); setSize(250, 250); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void actionPerformed(ActionEvent e) { int a = Integer.parseInt(fld1.getText()); int b = Integer.parseInt(fld2.getText()); int c = a + b; fld3.setText(String.valueOf(c)); } public static void main(String arg[]) { new EventTest(); } }
  • 12. Long Answer Question… 7. Java Beans • A reusable software component that can be manipulated visually in a ‘builder tool’. (from JavaBean Specification) • The JavaBeans API provides a framework for defining reusable, embeddable, modular software components • Software components written in Java • Event Handling
  • 13. Long Answer Question… 8. Applet  A Java applet is an applet delivered to users in the form of Java bytecode  Java applets can be part of a web page and executed by the Java Virtual Machine (JVM) in a process separate from the web browser, or run in Sun's AppletViewer  Give Example 9. Final Keyword  To make the constant  To stop the class from being inherited  Give Example
  • 14. 2011 Short Answer Question 1. What is bytecode?  Java bytecode is the form of instructions that the Java virtual machine executes 2. What is parameter marshalling?  Transfer of parameters (or marshalling) is done by the RMI 3. What is synchronization?  Synchronization is a feature by which only one thread can access a resource in a particular time of instance.  No other thread can interrupt for that resource
  • 15. Short Answer Question… 4. What is an exception?  An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions  Example :- NullPointerException, DivideByZeroException, dereference of a null pointer, out-of-bounds array access, attempt to open a non-existent file for reading 5. How do you create a new package in java? package <package_name> 6. Differentiate between AWT and Swing Heavyweight vs Lightweight
  • 16. Short Answer Question… 8. How does java support runtime polymorphism?  Function Overriding 9. Why are character streams more convenient for handling in java?  Text-based I/O works with streams of human-readable characters, while data-based I/O works with streams of binary data 10. Interface and abstract class  All methods of interface are by default abstract  Only abstract method of abstract class are abstract  Examples
  • 17. Long Answer Questions 1. Event handling with addition and subtraction Example 2. Thread priority  Every Java thread has a priority that helps the operating system determine the order in which threads are scheduled  ThreadObject.setPriority(num)  MIN (1) and MAX(10) NORMAL(5) 3. Socket  Programs manage each client connection with a Socket object  Socket allows the server to interact with the client  Example
  • 18. Long Answer Questions… 4. Prepared Statement
  • 19. 2012 Short Answer Question 1. What is SQLException If the DriverManager cannot connect to the database 2. Are the java always platform independent? No if java has called the native file 3. States of a thread in java New, Blocked, Running, Wait, Runnable 4. Name the event generated by the button ActionEvent, ItemEvent (by list items) 5. Use of import To import the API of java
  • 20. Short Answer Question… 6. rebind() method Register the server object in RMI 7. read() method To read the buffer string