注意:此页面搜索的是所有试题
江苏开放大学JAVA程序设计形成性考核作业1
简述可以用哪几种方法对文件进行读写。
从字节流到字符流的转化过程中,有哪些注意事项?
线程与进程有什么关系?
线程有几种状态,引起线程中断的主要原因有哪些?
一个线程执行完run()方法后,进入了什么状态?该线程还能再调用start()方法吗?
建立线程的方法有哪几种?Runnable接口在线程创建中的作用?
import java.io.*;
public class abc
{
public static void main(String args [ ])
{
AB s = new AB("Hello!","I love JAVA.");
System.out.println(s.toString( ));
}
}
class AB {
String s1;
String s2;
public AB(String str1, String str2)
{
s1 = str1;
s2 = str2;
}
public String toString( )
{
return s1+s2;
}
}
import java.io.* ;
public class abc
{
public static void main(String args[ ])
{ int i, s = 0 ;
int a[ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 };
for ( i = 0 ; i < a.length ; i ++ )
if ( a[i]%3 = = 0 ) s += a[i] ;
System.out.println("s="+s);
}
}
import java.io.* ;
public class abc
{
public static void main(String args[ ])
{
System.out.println("a="+a+"\nb="+b);
}
}
class SubClass extends SuperClass
{ int c;
SubClass(int aa, int bb, int cc)
{
super(aa, bb);
c=cc;
}
}
class SubSubClass extends SubClass
{ int a;
SubSubClass(int aa, int bb, int cc)
{ super(aa, bb, cc);
A = aa+bb+cc;
}
void show()
{
System.out.println("a="+a+"\nb="+b+"\nc="+c);
}
}
以下程序的输出结果为 。
class StringTest1
{
public static void main(String[] args)
{
String s1="hello";
String s2=new String("hello");
if(s1.equals(s2)){
System.out.println("相等");
}else{
System.out.println("不相等");
}
}
}
以下程序段的输出结果为 5 6 7 8 9 。
public class TestArray
{
public static void main(String args[ ]){
int i , j ;
int a[ ] = { 5,9,6,8,7};
for ( i = 0 ; i < a.length-1; i ++ ) {
int k = i;
for ( j = i ; j < a.length ; j++ )
if ( a[j]<a[k] ) k = j;
int temp =a[i];
a[i] = a[k];
a[k] = temp;
}
for ( i =0 ; i<a.length; i++ )
System.out.print(a[i]+" ");
System.out.println( );
}
}
阅读以下程序,写出输出结果。
class Animal {
Animal() {
System.out.print ("Animal "); }
}
public class Dog extends Animal {
Dog() {
System.out.print ("Dog "); }
public static void main(String[] args) {
Dog snoppy= new Dog(); }
}
以下程序的输出结果为________。
public class Person {
String name;
int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public static void main(String[] args) {
Person c = new Person("Peter", 17);
System.out.println(c.name + " is " + c.age + " years old!");
}
}
以下程序的输出结果为_____。
public class Course {
private String cNumber;
private String cName;
private int cUnit;
public Course(String number, String name, int unit) {
cNumber = number;
cName = name;
cUnit = unit;
}
public void printCourseInfo() {
System.out.println("课程号:" + cNumber + " 课程名:" + cName + " 学分:" + cUnit);
}
}
class CourseTest {
public static void main(String[] args) {
Course c;
c = new Course("101", "ASP", 3);
c.printCourseInfo();
}
}
以下程序的输出结果为_____。
public class Tom {
private float weight;
private static String name;
public void setWeight(float weight) {
this.weight = weight;
}
private void out() {
System.out.println(name + "体重:" + weight + "斤");
}
public static void main(String[] args) {
Tom.name = "汤姆猫";
Tom cat = new Tom();
cat.setWeight(20);
cat.out();
}
}
从字节流到字符流的转化过程中,有哪些注意事项?
线程与进程有什么关系?
线程有几种状态,引起线程中断的主要原因有哪些?
一个线程执行完run()方法后,进入了什么状态?该线程还能再调用start()方法吗?
建立线程的方法有哪几种?Runnable接口在线程创建中的作用?
import java.io.*;
public class abc
{
public static void main(String args [ ])
{
AB s = new AB("Hello!","I love JAVA.");
System.out.println(s.toString( ));
}
}
class AB {
String s1;
String s2;
public AB(String str1, String str2)
{
s1 = str1;
s2 = str2;
}
public String toString( )
{
return s1+s2;
}
}
import java.io.* ;
public class abc
{
public static void main(String args[ ])
{ int i, s = 0 ;
int a[ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 };
for ( i = 0 ; i < a.length ; i ++ )
if ( a[i]%3 = = 0 ) s += a[i] ;
System.out.println("s="+s);
}
}
import java.io.* ;
public class abc
{
public static void main(String args[ ])
{
System.out.println("a="+a+"\nb="+b);
}
}
class SubClass extends SuperClass
{ int c;
SubClass(int aa, int bb, int cc)
{
super(aa, bb);
c=cc;
}
}
class SubSubClass extends SubClass
{ int a;
SubSubClass(int aa, int bb, int cc)
{ super(aa, bb, cc);
A = aa+bb+cc;
}
void show()
{
System.out.println("a="+a+"\nb="+b+"\nc="+c);
}
}
以下程序的输出结果为 。
class StringTest1
{
public static void main(String[] args)
{
String s1="hello";
String s2=new String("hello");
if(s1.equals(s2)){
System.out.println("相等");
}else{
System.out.println("不相等");
}
}
}
以下程序段的输出结果为 5 6 7 8 9 。
public class TestArray
{
public static void main(String args[ ]){
int i , j ;
int a[ ] = { 5,9,6,8,7};
for ( i = 0 ; i < a.length-1; i ++ ) {
int k = i;
for ( j = i ; j < a.length ; j++ )
if ( a[j]<a[k] ) k = j;
int temp =a[i];
a[i] = a[k];
a[k] = temp;
}
for ( i =0 ; i<a.length; i++ )
System.out.print(a[i]+" ");
System.out.println( );
}
}
阅读以下程序,写出输出结果。
class Animal {
Animal() {
System.out.print ("Animal "); }
}
public class Dog extends Animal {
Dog() {
System.out.print ("Dog "); }
public static void main(String[] args) {
Dog snoppy= new Dog(); }
}
以下程序的输出结果为________。
public class Person {
String name;
int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public static void main(String[] args) {
Person c = new Person("Peter", 17);
System.out.println(c.name + " is " + c.age + " years old!");
}
}
以下程序的输出结果为_____。
public class Course {
private String cNumber;
private String cName;
private int cUnit;
public Course(String number, String name, int unit) {
cNumber = number;
cName = name;
cUnit = unit;
}
public void printCourseInfo() {
System.out.println("课程号:" + cNumber + " 课程名:" + cName + " 学分:" + cUnit);
}
}
class CourseTest {
public static void main(String[] args) {
Course c;
c = new Course("101", "ASP", 3);
c.printCourseInfo();
}
}
以下程序的输出结果为_____。
public class Tom {
private float weight;
private static String name;
public void setWeight(float weight) {
this.weight = weight;
}
private void out() {
System.out.println(name + "体重:" + weight + "斤");
}
public static void main(String[] args) {
Tom.name = "汤姆猫";
Tom cat = new Tom();
cat.setWeight(20);
cat.out();
}
}